Skip to content

Commit a504595

Browse files
C-Elegansalberthdev
authored andcommitted
Add option to print help message
Refactor the help message into its own function Add -h and -H as options to print the help message and exit
1 parent 93240f7 commit a504595

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

main.cpp

+32-24
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,33 @@ int run_assembly()
217217
printf("Assembly time: %0.3f seconds\n", (float) s_diff + ((float) ms_diff / 1000.0f));
218218
return exit_code;
219219
}
220+
void print_help_message(void){
221+
puts ("SPASM-ng Z80 Assembler by Spencer Putt and Don Straney");
222+
printf ("Version %s (built on %s @ %s)\n", SPASM_NG_VERSION, __DATE__, __TIME__);
223+
#ifdef SPASM_NG_GITREV
224+
printf ("Git revision %s\n", SPASM_NG_GITREV);
225+
#endif
226+
#ifdef _M_X64
227+
puts ("64-bit Version");
228+
#endif
229+
#ifdef NO_APPSIGN
230+
printf ("\nApp signing is NOT available in this build of SPASM.\n");
231+
#endif
232+
puts ("\nspasm [options] <input file> <output file>\n");
233+
puts ("Options:\n-E = Assemble eZ80 code\n-T = Generate code listing\n-C = Code counter mode\n-L = Symbol table mode\n-S = Stats mode\n-O = Don't write to output file");
234+
puts ("-I [directory] = Add include directory\n-A = Labels are cAse-sensitive\n-D<name>[=value] = Create a define 'name' [with 'value']");
235+
puts ("-N = Don't use colors for messages");
236+
puts ("-V <Expression> = Pipe expression directly into assembly");
237+
puts ("-H = Print this help message");
238+
239+
#if defined(_DEBUG) && defined(WIN32)
240+
if (IsDebuggerPresent())
241+
{
242+
system("PAUSE");
243+
}
244+
#endif
245+
exit(EXIT_NORMAL);
246+
}
220247

221248
#if 0
222249
int CALLBACK WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCommandLine, int nCmdShow)
@@ -237,30 +264,7 @@ int main (int argc, char **argv)
237264

238265
//if there aren't enough args, show info
239266
if (argc < 2) {
240-
puts ("SPASM-ng Z80 Assembler by Spencer Putt and Don Straney");
241-
printf ("Version %s (built on %s @ %s)\n", SPASM_NG_VERSION, __DATE__, __TIME__);
242-
#ifdef SPASM_NG_GITREV
243-
printf ("Git revision %s\n", SPASM_NG_GITREV);
244-
#endif
245-
#ifdef _M_X64
246-
puts ("64-bit Version");
247-
#endif
248-
#ifdef NO_APPSIGN
249-
printf ("\nApp signing is NOT available in this build of SPASM.\n");
250-
#endif
251-
puts ("\nspasm [options] <input file> <output file>\n");
252-
puts ("Options:\n-E = Assemble eZ80 code\n-T = Generate code listing\n-C = Code counter mode\n-L = Symbol table mode\n-S = Stats mode\n-O = Don't write to output file");
253-
puts ("-I [directory] = Add include directory\n-A = Labels are cAse-sensitive\n-D<name>[=value] = Create a define 'name' [with 'value']");
254-
puts ("-N = Don't use colors for messages");
255-
puts ("-V <Expression> = Pipe expression directly into assembly");
256-
257-
#if defined(_DEBUG) && defined(WIN32)
258-
if (IsDebuggerPresent())
259-
{
260-
system("PAUSE");
261-
}
262-
#endif
263-
return EXIT_NORMAL;
267+
print_help_message();
264268
}
265269

266270
//init stuff
@@ -388,6 +392,10 @@ int main (int argc, char **argv)
388392
strcat(input_contents, "\n");
389393
break;
390394
}
395+
case 'H':
396+
case 'h':
397+
print_help_message();
398+
break;
391399
default:
392400
{
393401
#ifndef _TEST

0 commit comments

Comments
 (0)