mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
fish: In interactive mode, improve error message for help of unknown command (RHBZ#1497475)
This commit is contained in:
committed by
Richard W.M. Jones
parent
6127852d24
commit
fcacda8374
18
fish/fish.c
18
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1365,11 +1365,14 @@ other words, they are not part of the L<guestfs(3)> API.
|
||||
|
||||
help
|
||||
help cmd
|
||||
help -l|--list
|
||||
|
||||
Without any parameter, this provides general help.
|
||||
|
||||
With a C<cmd> parameter, this displays detailed help for that command.
|
||||
|
||||
With I<-l> or I<--list>, this list all commands.
|
||||
|
||||
=head2 exit
|
||||
|
||||
=head2 quit
|
||||
|
||||
41
fish/help.c
41
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 <cmd>' or 'help -l|--list' to list all commands\n"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user