From 74f7c9e4b7e27787e2052166eeedfbac5814200b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 4 Nov 2010 17:04:03 +0000 Subject: [PATCH] fish: Make the 'help' command more helpful. --- fish/Makefile.am | 1 + fish/fish.c | 4 ++-- fish/fish.h | 3 +++ fish/guestfish.pod | 5 +++-- fish/help.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + 6 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 fish/help.c diff --git a/fish/Makefile.am b/fish/Makefile.am index 89cc4ec..61b6346 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -62,6 +62,7 @@ guestfish_SOURCES = \ fish.c \ fish.h \ glob.c \ + help.c \ hexedit.c \ lcd.c \ man.c \ diff --git a/fish/fish.c b/fish/fish.c index 559d609..54fd270 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -626,7 +626,7 @@ script (int prompt) "Welcome to guestfish, the libguestfs filesystem interactive shell for\n" "editing virtual machine filesystems.\n" "\n" - "Type: 'help' for a list of commands\n" + "Type: 'help' for help on commands\n" " 'man' to read the manual\n" " 'quit' to quit the shell\n" "\n")); @@ -925,7 +925,7 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd) /* Otherwise execute it locally. */ else if (STRCASEEQ (cmd, "help")) { if (argc == 0) { - list_commands (); + display_help (); r = 0; } else r = display_command (argv[0]); diff --git a/fish/fish.h b/fish/fish.h index ac44bbf..a3f7caf 100644 --- a/fish/fish.h +++ b/fish/fish.h @@ -109,6 +109,9 @@ extern int run_echo (const char *cmd, size_t argc, char *argv[]); /* in edit.c */ extern int run_edit (const char *cmd, size_t argc, char *argv[]); +/* in help.c */ +extern void display_help (void); + /* in hexedit.c */ extern int run_hexedit (const char *cmd, size_t argc, char *argv[]); diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 4f4e1f0..7319bd7 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -846,8 +846,9 @@ other words, they are not part of the L API. help help cmd -Without any parameter, this lists all commands. With a C -parameter, this displays detailed help for a command. +Without any parameter, this provides general help. + +With a C parameter, this displays detailed help for that command. =head2 quit | exit diff --git a/fish/help.c b/fish/help.c new file mode 100644 index 0000000..47609e9 --- /dev/null +++ b/fish/help.c @@ -0,0 +1,58 @@ +/* guestfish - the filesystem interactive shell + * Copyright (C) 2010 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +#include +#include +#include +#include + +#include "fish.h" + +/* The "help" command. This used to just list all commands, but + * that's not very useful. Instead display some useful + * context-sensitive help. This could be improved if we knew how many + * drives had been added already, and whether anything was mounted. + */ +void +display_help (void) +{ + if (guestfs_is_config (g)) + printf (_( +"Add disk images to examine using the -a or -d options, or the 'add' 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 (_( +"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-options'.\n" + )); + + printf ("\n"); + + printf (_( +"For more information about a command, use 'help cmd'.\n" +"\n" +"To read the manual, type 'man'.\n" + )); + + printf ("\n"); +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 877db69..fbb040d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -81,6 +81,7 @@ fish/echo.c fish/edit.c fish/fish.c fish/glob.c +fish/help.c fish/hexedit.c fish/inspect.c fish/lcd.c -- 1.8.3.1