X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=cli%2Fcli_main.cpp;h=1e278e41381d1d4860175a84b7b058369d338757;hb=d6b7eb6b7c8280762fb635a6e63aa3a426694ed7;hp=421748ca171fab39f67e19b18eca89cdfababfca;hpb=32420d2167c14c4c00d351e8807031b64bce06ef;p=apitrace diff --git a/cli/cli_main.cpp b/cli/cli_main.cpp index 421748c..1e278e4 100644 --- a/cli/cli_main.cpp +++ b/cli/cli_main.cpp @@ -67,11 +67,31 @@ const Command help_command = { static const Command * commands[] = { &diff_command, + &diff_state_command, + &diff_images_command, &dump_command, + &dump_images_command, + &pickle_command, + &sed_command, + &repack_command, + &retrace_command, &trace_command, + &trim_command, &help_command }; +/* Aliases provide a mechanism to allow compatibility with old command + * names (such as "retrace") for current commands (such as the replay + * command). */ +typedef struct { + const char *name; + const Command *command; +} Alias; + +static const Alias aliases[] = { + { "retrace", &retrace_command } +}; + static void usage(void) { @@ -117,12 +137,12 @@ do_help_command(int argc, char *argv[]) const Command *command; int i; - if (argc != 1) { + if (argc != 2) { help_usage(); return 0; } - char *command_name = argv[0]; + char *command_name = argv[1]; for (i = 0; i < ARRAY_SIZE(commands); i++) { command = commands[i]; @@ -144,6 +164,7 @@ main(int argc, char **argv) { const char *command_name; const Command *command; + const Alias *alias; int i; for (i = 1; i < argc; ++i) { @@ -167,7 +188,7 @@ main(int argc, char **argv) return 1; } - command_name = argv[i++]; + command_name = argv[i]; argc -= i; argv = &argv[i]; @@ -179,8 +200,15 @@ main(int argc, char **argv) return (command->function) (argc, argv); } + for (i = 0; i < ARRAY_SIZE(aliases); i++) { + alias = &aliases[i]; + + if (strcmp(command_name, alias->name) == 0) + return (alias->command->function) (argc, argv); + } + std::cerr << "Error: unknown command " << command_name << " (see \"apitrace help\").\n"; - return 1; + return 1; }