File: help.c

package info (click to toggle)
libguestfs 1%3A1.54.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 98,888 kB
  • sloc: ansic: 379,443; ml: 38,771; sh: 10,328; java: 9,631; cs: 6,377; haskell: 5,729; makefile: 5,178; python: 3,821; perl: 2,467; erlang: 2,461; ruby: 349; xml: 275; pascal: 257; javascript: 157; cpp: 10
file content (84 lines) | stat: -rw-r--r-- 2,440 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* guestfish - guest filesystem shell
 * Copyright (C) 2010-2023 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/**
 * The file implements the guestfish C<help> command.
 */

#include <config.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libintl.h>

#include "fish.h"

/**
 * The C<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.
 */
int
display_help (const char *cmd, size_t argc, char *argv[])
{
  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 (_(
"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 (_(
"For more information about a command, use ‘help cmd’.\n"
"\n"
"To read the manual, type ‘man’.\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;
  }
}