summaryrefslogtreecommitdiffstats
path: root/fish/fish.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-04-06 23:54:08 +0100
committerRichard Jones <rjones@redhat.com>2010-04-07 12:06:07 +0100
commit4c50f4c38d9a50fbf983c79dd208d1b1598fef8a (patch)
treece781f324d58384eae82845bd828aad839744882 /fish/fish.c
parent2ade61d1f864c75ce65c358e4ac8a012a897b89a (diff)
downloadlibguestfs-4c50f4c38d9a50fbf983c79dd208d1b1598fef8a.tar.gz
libguestfs-4c50f4c38d9a50fbf983c79dd208d1b1598fef8a.tar.xz
libguestfs-4c50f4c38d9a50fbf983c79dd208d1b1598fef8a.zip
fish: Print extended help when the user types an unknown command first.
$ guestfish /tmp/disk.img /tmp/disk.img: unknown command Did you mean to open a disk image? guestfish -a disk.img For a list of commands: guestfish -h For complete documentation: man guestfish
Diffstat (limited to 'fish/fish.c')
-rw-r--r--fish/fish.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fish/fish.c b/fish/fish.c
index 2022ee3a..bd13a827 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -73,6 +73,7 @@ int echo_commands = 0;
int remote_control_listen = 0;
int remote_control = 0;
int exit_on_error = 1;
+int command_num = 0;
int
launch (guestfs_h *_g)
@@ -790,6 +791,9 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd)
int pid = 0;
int i, r;
+ /* This counts the commands issued, starting at 1. */
+ command_num++;
+
if (echo_commands) {
printf ("%s", cmd);
for (i = 0; argv[i] != NULL; ++i)
@@ -1073,6 +1077,21 @@ display_builtin_command (const char *cmd)
cmd);
}
+/* This is printed when the user types in an unknown command for the
+ * first command issued. A common case is the user doing:
+ * guestfish disk.img
+ * expecting guestfish to open 'disk.img' (in fact, this tried to
+ * run a command 'disk.img').
+ */
+void
+extended_help_message (void)
+{
+ fprintf (stderr,
+ _("Did you mean to open a disk image? guestfish -a disk.img\n"
+ "For a list of commands: guestfish -h\n"
+ "For complete documentation: man guestfish\n"));
+}
+
void
free_strings (char **argv)
{