diff --git a/fish/fish.c b/fish/fish.c index 576908f5d..a4ab7b733 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -1169,13 +1169,8 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd, r = rc_remote (remote_control, cmd, argc, argv, rc_exit_on_error_flag); /* Otherwise execute it locally. */ - else if (STRCASEEQ (cmd, "help")) { - if (argc == 0) { - display_help (); - r = 0; - } else - r = display_command (argv[0]); - } + else if (STRCASEEQ (cmd, "help")) + r = display_help (cmd, argc, argv); else if (STRCASEEQ (cmd, "quit") || STRCASEEQ (cmd, "exit") || STRCASEEQ (cmd, "q")) { @@ -1239,6 +1234,7 @@ display_builtin_command (const char *cmd) if (STRCASEEQ (cmd, "help")) { printf (_("help - display a list of commands or help on a command\n" + " help --list\n" " help cmd\n" " help\n")); return 0; @@ -1251,8 +1247,12 @@ display_builtin_command (const char *cmd) return 0; } else { - fprintf (stderr, _("%s: command not known, use -h to list all commands\n"), - cmd); + fprintf (stderr, _("%s: command not known: "), cmd); + if (is_interactive) { + fprintf (stderr, _("use 'help --list' to list all commands\n")); + } else { + fprintf (stderr, _("use -h to list all commands\n")); + } return -1; } } diff --git a/fish/fish.h b/fish/fish.h index c610a0a2f..f4856954a 100644 --- a/fish/fish.h +++ b/fish/fish.h @@ -76,7 +76,7 @@ extern int alloc_disk (const char *filename, const char *size, extern int parse_size (const char *str, off_t *size_rtn); /* in help.c */ -extern void display_help (void); +extern int display_help (const char *cmd, size_t argc, char *argv[]); /* in prep.c */ struct prep_data { diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 1201176e9..11f2bbeb5 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -1365,11 +1365,14 @@ other words, they are not part of the L API. help help cmd + help -l|--list Without any parameter, this provides general help. With a C parameter, this displays detailed help for that command. +With I<-l> or I<--list>, this list all commands. + =head2 exit =head2 quit diff --git a/fish/help.c b/fish/help.c index 18e540018..36771c31b 100644 --- a/fish/help.c +++ b/fish/help.c @@ -38,30 +38,47 @@ * improved if we knew how many drives had been added already, and * whether anything was mounted. */ -void -display_help (void) +int +display_help (const char *cmd, size_t argc, char *argv[]) { - if (guestfs_is_config (g)) - printf (_( + if (argc == 0) { + if (guestfs_is_config (g)) + printf (_( "Add disk images to examine using the ‘-a’ or ‘-d’ options, or the ‘add’\n" "command.\n" "Or create a new disk image using ‘-N’, or the ‘alloc’ or ‘sparse’ commands.\n" "Once you have done this, use the ‘run’ command.\n" - )); - else - printf (_( + )); + else + printf (_( "Find out what filesystems are available using ‘list-filesystems’ and then\n" "mount them to examine or modify the contents using ‘mount-ro’ or\n" "‘mount’.\n" - )); + )); - printf ("\n"); + printf ("\n"); - printf (_( + printf (_( "For more information about a command, use ‘help cmd’.\n" "\n" "To read the manual, type ‘man’.\n" - )); + )); - printf ("\n"); + printf ("\n"); + + return 0; + } + else if (argc == 1) { + if (STREQ (argv[0], "--list") || STREQ (argv[0], "-l")) { + /* List all commands. */ + list_commands (); + return 0; + } + else + return display_command (argv[0]); + } + else { + fprintf (stderr, _("use 'help', 'help ' or 'help -l|--list' to list all commands\n")); + return -1; + } }