Skip to content

Commit 838f212

Browse files
committed
unix/main: Add --version command-line option.
CPython also has this option. Signed-off-by: Damien George <[email protected]>
1 parent 51663b9 commit 838f212

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ports/unix/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ static void print_help(char **argv) {
318318
printf(
319319
"usage: %s [<opts>] [-X <implopt>] [-c <command> | -m <module> | <filename>]\n"
320320
"Options:\n"
321+
"--version : show version information\n"
321322
"-h : print this help message\n"
322323
"-i : enable inspection via REPL after running command/module/file\n"
323324
#if MICROPY_DEBUG_PRINTERS
@@ -369,6 +370,10 @@ static void pre_process_options(int argc, char **argv) {
369370
print_help(argv);
370371
exit(0);
371372
}
373+
if (strcmp(argv[a], "--version") == 0) {
374+
printf(MICROPY_BANNER_NAME_AND_VERSION "; " MICROPY_BANNER_MACHINE "\n");
375+
exit(0);
376+
}
372377
if (strcmp(argv[a], "-X") == 0) {
373378
if (a + 1 >= argc) {
374379
exit(invalid_args());

0 commit comments

Comments
 (0)