diff --git a/pygrt/C_extension/src/grt.c b/pygrt/C_extension/src/grt.c index 43e127a0..4ab0a951 100644 --- a/pygrt/C_extension/src/grt.c +++ b/pygrt/C_extension/src/grt.c @@ -46,23 +46,38 @@ print_logo(); printf("\n" "Usage: \n" "----------------------------------------------------------------\n" -" grt [options] ...\n\n\n"); +" grt [options]\n" +" grt [] ...\n\n\n" +"Options:\n" +"----------------------------------------------------------------\n" +" -v Display the program version.\n" +"\n" +" -h Display this help message.\n" +"\n\n"); printf("GRT supports the following submodules:\n" "----------------------------------------------------------------\n"); for (MYINT n = 0; GRT_Submodule_Names[n] != NULL; ++n) { const char *name = GRT_Submodule_Names[n]; printf(" %-s\n", name); } -printf("\n\n"); -printf("For each submodule, you can use -h to see the help message.\n\n"); +printf("\n" +"For each submodule, you can use -h to see its help message, e.g.\n" +" grt greenfn -h \n" +"\n"); } /** 从命令行中读取选项,处理后记录到参数控制结构体 */ static void getopt_from_command(GRT_MAIN_CTRL *Ctrl, int argc, char **argv){ char* command = Ctrl->name; int opt; - while ((opt = getopt(argc, argv, ":h")) != -1) { + while ((opt = getopt(argc, argv, ":vh")) != -1) { switch (opt) { + // 打印版本 + case 'v': + printf(GRT_MAIN_COMMAND" %s\n", GRT_VERSION); + exit(EXIT_SUCCESS); + break; + GRT_Common_Options_in_Switch(command, optopt); } }