Skip to content

Commit 1191467

Browse files
committed
Merge branch 'jk/test-tool-help'
Developer support. * jk/test-tool-help: test-tool: show tool list on error
2 parents 4b73fda + 4e26569 commit 1191467

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

t/helper/test-tool.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,23 @@ static struct test_cmd cmds[] = {
5555
{ "write-cache", cmd__write_cache },
5656
};
5757

58+
static NORETURN void die_usage(void)
59+
{
60+
size_t i;
61+
62+
fprintf(stderr, "usage: test-tool <toolname> [args]\n");
63+
for (i = 0; i < ARRAY_SIZE(cmds); i++)
64+
fprintf(stderr, " %s\n", cmds[i].name);
65+
exit(128);
66+
}
67+
5868
int cmd_main(int argc, const char **argv)
5969
{
6070
int i;
6171

6272
BUG_exit_code = 99;
6373
if (argc < 2)
64-
die("I need a test name!");
74+
die_usage();
6575

6676
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
6777
if (!strcmp(cmds[i].name, argv[1])) {
@@ -70,5 +80,6 @@ int cmd_main(int argc, const char **argv)
7080
return cmds[i].fn(argc, argv);
7181
}
7282
}
73-
die("There is no test named '%s'", argv[1]);
83+
error("there is no tool named '%s'", argv[1]);
84+
die_usage();
7485
}

0 commit comments

Comments
 (0)