X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=cli%2Fcli_main.cpp;h=d6db6196121b3d5a9a158c29309c1e7f556a02c8;hb=7a9fb5103e052150232b64cb5d99374cda3f1234;hp=cff6a05de111955323219d8575ba7400d955f174;hpb=ee659c84695e9f94b1f6a5f8be203dc0012ca685;p=apitrace diff --git a/cli/cli_main.cpp b/cli/cli_main.cpp index cff6a05..d6db619 100644 --- a/cli/cli_main.cpp +++ b/cli/cli_main.cpp @@ -70,13 +70,27 @@ static const Command * commands[] = { &diff_state_command, &diff_images_command, &dump_command, + &dump_images_command, &pickle_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) { @@ -149,6 +163,7 @@ main(int argc, char **argv) { const char *command_name; const Command *command; + const Alias *alias; int i; for (i = 1; i < argc; ++i) { @@ -184,6 +199,13 @@ 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";