unix: Use argv[0] for command name in usage.

This commit is contained in:
Paul Sokolovsky 2014-04-02 20:31:18 +03:00
parent a55a5469c3
commit d440dc0513

View File

@ -213,11 +213,11 @@ mp_obj_t test_obj_new(int value) {
return o; return o;
} }
int usage(void) { int usage(char **argv) {
printf( printf(
"usage: py [-X <opt>] [-c <command>] [<filename>]\n" "usage: %s [-X <opt>] [-c <command>] [<filename>]\n"
"\n" "\n"
"Implementation specific options:\n" "Implementation specific options:\n", argv[0]
); );
int impl_opts_cnt = 0; int impl_opts_cnt = 0;
#if MICROPY_ENABLE_GC #if MICROPY_ENABLE_GC
@ -261,7 +261,7 @@ void pre_process_options(int argc, char **argv) {
if (argv[a][0] == '-') { if (argv[a][0] == '-') {
if (strcmp(argv[a], "-X") == 0) { if (strcmp(argv[a], "-X") == 0) {
if (a + 1 >= argc) { if (a + 1 >= argc) {
exit(usage()); exit(usage(argv));
} }
if (0) { if (0) {
#if MICROPY_ENABLE_GC #if MICROPY_ENABLE_GC
@ -269,7 +269,7 @@ void pre_process_options(int argc, char **argv) {
heap_size = strtol(argv[a + 1] + sizeof("heapsize=") - 1, NULL, 0); heap_size = strtol(argv[a + 1] + sizeof("heapsize=") - 1, NULL, 0);
#endif #endif
} else { } else {
exit(usage()); exit(usage(argv));
} }
a++; a++;
} }
@ -370,7 +370,7 @@ int main(int argc, char **argv) {
if (argv[a][0] == '-') { if (argv[a][0] == '-') {
if (strcmp(argv[a], "-c") == 0) { if (strcmp(argv[a], "-c") == 0) {
if (a + 1 >= argc) { if (a + 1 >= argc) {
return usage(); return usage(argv);
} }
do_str(argv[a + 1]); do_str(argv[a + 1]);
executed = true; executed = true;
@ -378,7 +378,7 @@ int main(int argc, char **argv) {
} else if (strcmp(argv[a], "-X") == 0) { } else if (strcmp(argv[a], "-X") == 0) {
a += 1; a += 1;
} else { } else {
return usage(); return usage(argv);
} }
} else { } else {
char *basedir = realpath(argv[a], NULL); char *basedir = realpath(argv[a], NULL);