| 106 | } |
| 107 | |
| 108 | int cmd_main(int argc, const char **argv) |
| 109 | { |
| 110 | const char *working_directory = NULL; |
| 111 | struct option options[] = { |
| 112 | OPT_STRING('C', NULL, &working_directory, "directory", |
| 113 | "change the working directory"), |
| 114 | OPT_END() |
| 115 | }; |
| 116 | |
| 117 | BUG_exit_code = 99; |
| 118 | argc = parse_options(argc, argv, NULL, options, test_tool_usage, |
| 119 | PARSE_OPT_STOP_AT_NON_OPTION | |
| 120 | PARSE_OPT_KEEP_ARGV0); |
| 121 | |
| 122 | if (argc < 2) |
| 123 | die_usage(); |
| 124 | |
| 125 | if (working_directory && chdir(working_directory) < 0) |
| 126 | die("Could not cd to '%s'", working_directory); |
| 127 | |
| 128 | for (size_t i = 0; i < ARRAY_SIZE(cmds); i++) { |
| 129 | if (!strcmp(cmds[i].name, argv[1])) { |
| 130 | argv++; |
| 131 | argc--; |
| 132 | trace2_cmd_name(cmds[i].name); |
| 133 | trace2_cmd_list_config(); |
| 134 | trace2_cmd_list_env_vars(); |
| 135 | return cmds[i].fn(argc, argv); |
| 136 | } |
| 137 | } |
| 138 | error("there is no tool named '%s'", argv[1]); |
| 139 | die_usage(); |
| 140 | } |
nothing calls this directly
no test coverage detected