From 7a25e2efe9360b333fedc3fb938774437703700e Mon Sep 17 00:00:00 2001 From: James Peach Date: Sun, 21 Mar 2010 22:04:37 -0700 Subject: smbtorture: Enhance shell "help" command. Sort the command list alphabetically. Let the help command print usage info for other commands. --- source4/torture/shell.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/shell.c b/source4/torture/shell.c index a0f9d7d3a3..888097de7f 100644 --- a/source4/torture/shell.c +++ b/source4/torture/shell.c @@ -58,13 +58,14 @@ struct shell_command static const struct shell_command commands[] = { { - shell_help, "help", NULL, - "print this help message" + shell_auth, "auth", + "[[username | principal | domain | realm | password] STRING]", + "set authentication parameters" }, { - shell_quit, "quit", NULL, - "exit smbtorture" + shell_help, "help", NULL, + "print this help message" }, { @@ -73,8 +74,8 @@ static const struct shell_command commands[] = }, { - shell_set, "set", "[NAME VALUE]", - "print or set test configuration parameters" + shell_quit, "quit", NULL, + "exit smbtorture" }, { @@ -83,10 +84,10 @@ static const struct shell_command commands[] = }, { - shell_auth, "auth", - "[[username | principal | domain | realm | password] STRING]", - "set authentication parameters" + shell_set, "set", "[NAME VALUE]", + "print or set test configuration parameters" } + }; void torture_shell(struct torture_context *tctx) @@ -147,10 +148,19 @@ static void shell_help(const struct shell_command * command, { int i; - fprintf(stdout, "Available commands:\n"); - for (i = 0; i < ARRAY_SIZE(commands); i++) { - fprintf(stdout, "\t%s - %s\n", - commands[i].name, commands[i].help); + if (argc == 1) { + for (i = 0; i < ARRAY_SIZE(commands); i++) { + if (match_command(argv[0], &commands[i])) { + shell_usage(&commands[i]); + return; + } + } + } else { + fprintf(stdout, "Available commands:\n"); + for (i = 0; i < ARRAY_SIZE(commands); i++) { + fprintf(stdout, "\t%s - %s\n", + commands[i].name, commands[i].help); + } } } -- cgit