]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2005-07-17 Yoshinori Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Sun, 17 Jul 2005 20:26:07 +0000 (20:26 +0000)
committerokuji <okuji@localhost>
Sun, 17 Jul 2005 20:26:07 +0000 (20:26 +0000)
* commands/cat.c (GRUB_MOD_INIT): Use better documentation.
(grub_cat_init): Likewise.
* loader/i386/pc/chainloader_normal.c (GRUB_MOD_INIT): Likewise.
(options): Likewise.
* commands/configfile.c (GRUB_MOD_INIT): Likewise.
(grub_configfile_init): Likewise.
* font/manager.c (GRUB_MOD_INIT): Likewise.
* commands/help.c (GRUB_MOD_INIT): Likewise.
(grub_help_init): Likewise.
* normal/command.c (grub_command_init): Likewise.
* loader/i386/pc/linux_normal.c (GRUB_MOD_INIT): Likewise.
* disk/loopback.c (grub_loop_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* commands/ls.c (grub_ls_init): Likewise.
(GRUB_MOD_INIT): Likewise.
(options): Likewise.
* commands/boot.c (grub_boot_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* loader/i386/pc/multiboot_normal.c (GRUB_MOD_INIT): Likewise.
* commands/i386/pc/reboot.c (grub_reboot_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* commands/cmp.c (grub_cmp_init): Likewise.
(GRUB_MOD_INIT): Likewise.

* normal/arg.c: Use <> instead of "" to include header files.
(SHORT_ARG_HELP): New macro.
(SHORT_ARG_USAGE): Likewise.
(help_options): Specify SHORT_ARG_HELP and SHORT_ARG_USAGE instead
of 'h' and 'u' for help and usage, respectively. Use more GNU-like
descriptions.
(find_short): Check if C is 'h' or 'u' explicitly.
(grub_arg_show_help): Use space characters instead of tabs. Treat
SHORT_ARG_HELP and SHORT_ARG_USAGE exceptionally so that -h and -u
are shown with --help and --usage only if they are not used for
the command itself.
(parse_option): Use SHORT_ARG_HELP and SHORT_ARG_USAGE instead of
'h' and 'u'.

* include/grub/arg.h (struct grub_arg_option): Add the qualifier
const into "longarg". Change the type of "shortarg" to int.

17 files changed:
ChangeLog
commands/boot.c
commands/cat.c
commands/cmp.c
commands/configfile.c
commands/help.c
commands/i386/pc/halt.c
commands/i386/pc/reboot.c
commands/ls.c
disk/loopback.c
font/manager.c
include/grub/arg.h
loader/i386/pc/chainloader_normal.c
loader/i386/pc/linux_normal.c
loader/i386/pc/multiboot_normal.c
normal/arg.c
normal/command.c

index e1aa12fdcfbc868cd419fb03ad0e6a35aada0f87..715fc2e2a7eef9ae292a28fdf0a96049880a32dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2005-07-17  Yoshinori Okuji  <okuji@enbug.org>
+
+       * commands/cat.c (GRUB_MOD_INIT): Use better documentation.
+       (grub_cat_init): Likewise.
+       * loader/i386/pc/chainloader_normal.c (GRUB_MOD_INIT): Likewise.
+       (options): Likewise.
+       * commands/configfile.c (GRUB_MOD_INIT): Likewise.
+       (grub_configfile_init): Likewise.
+       * font/manager.c (GRUB_MOD_INIT): Likewise.
+       * commands/help.c (GRUB_MOD_INIT): Likewise.
+       (grub_help_init): Likewise.
+       * normal/command.c (grub_command_init): Likewise.
+       * loader/i386/pc/linux_normal.c (GRUB_MOD_INIT): Likewise.
+       * disk/loopback.c (grub_loop_init): Likewise.
+       (GRUB_MOD_INIT): Likewise.
+       * commands/ls.c (grub_ls_init): Likewise.
+       (GRUB_MOD_INIT): Likewise.
+       (options): Likewise.
+       * commands/boot.c (grub_boot_init): Likewise.
+       (GRUB_MOD_INIT): Likewise.
+       * loader/i386/pc/multiboot_normal.c (GRUB_MOD_INIT): Likewise.
+       * commands/i386/pc/reboot.c (grub_reboot_init): Likewise.
+       (GRUB_MOD_INIT): Likewise.
+       * commands/cmp.c (grub_cmp_init): Likewise.
+       (GRUB_MOD_INIT): Likewise.
+
+       * normal/arg.c: Use <> instead of "" to include header files.
+       (SHORT_ARG_HELP): New macro.
+       (SHORT_ARG_USAGE): Likewise.
+       (help_options): Specify SHORT_ARG_HELP and SHORT_ARG_USAGE instead
+       of 'h' and 'u' for help and usage, respectively. Use more GNU-like
+       descriptions.
+       (find_short): Check if C is 'h' or 'u' explicitly.
+       (grub_arg_show_help): Use space characters instead of tabs. Treat
+       SHORT_ARG_HELP and SHORT_ARG_USAGE exceptionally so that -h and -u
+       are shown with --help and --usage only if they are not used for
+       the command itself.
+       (parse_option): Use SHORT_ARG_HELP and SHORT_ARG_USAGE instead of
+       'h' and 'u'.
+
+       * include/grub/arg.h (struct grub_arg_option): Add the qualifier
+       const into "longarg". Change the type of "shortarg" to int.
+
 2005-07-17  Yoshinori Okuji  <okuji@enbug.org>
 
        * boot/i386/pc/boot.S (boot_drive_check): New label.
index 79d9105e31ae776af882f5fb74a842767a4bb3eb..317af3672473411fb8965ef60b3ee6e6edac1e49 100644 (file)
@@ -1,7 +1,7 @@
 /* boot.c - command to boot an operating system */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2005  Free Software Foundation, Inc.
  *
  *  GRUB is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -43,7 +43,7 @@ void
 grub_boot_init (void)
 {
   grub_register_command ("boot", grub_cmd_boot, GRUB_COMMAND_FLAG_BOTH,
-                        "boot", "Boot an operating system", 0);
+                        "boot", "Boot an operating system.", 0);
 }
 
 void
@@ -54,9 +54,9 @@ grub_boot_fini (void)
 #else /* ! GRUB_UTIL */
 GRUB_MOD_INIT
 {
-  (void)mod;                   /* To stop warning. */
+  (void) mod;                  /* To stop warning. */
   grub_register_command ("boot", grub_cmd_boot, GRUB_COMMAND_FLAG_BOTH,
-                        "boot", "Boot an operating system", 0);
+                        "boot", "Boot an operating system.", 0);
 }
 
 GRUB_MOD_FINI
index fb1141fdf3192d23e3a2a7f174a99b84d5ab7eb5..ca945a9a1ebac65e282da73c507eaeebed62af0d 100644 (file)
@@ -1,7 +1,7 @@
 /* cat.c - command to show the contents of a file  */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2005  Free Software Foundation, Inc.
  *
  *  GRUB is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -74,7 +74,7 @@ void
 grub_cat_init (void)
 {
   grub_register_command ("cat", grub_cmd_cat, GRUB_COMMAND_FLAG_BOTH,
-                        "cat FILE", "Show the contents of a file", 0);
+                        "cat FILE", "Show the contents of a file.", 0);
 }
 
 void
@@ -85,9 +85,9 @@ grub_cat_fini (void)
 #else /* ! GRUB_UTIL */
 GRUB_MOD_INIT
 {
-  (void)mod;                   /* To stop warning. */
+  (void) mod;                  /* To stop warning. */
   grub_register_command ("cat", grub_cmd_cat, GRUB_COMMAND_FLAG_BOTH,
-                        "cat FILE", "Show the contents of a file", 0);
+                        "cat FILE", "Show the contents of a file.", 0);
 }
 
 GRUB_MOD_FINI
index a74f7d672b729d9daf740b01db78417eb466ae27..cf5bd7e09d9d542e50de22da165a21ce48961239 100644 (file)
@@ -1,7 +1,7 @@
 /* cmd.c - command to cmp an operating system */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2005  Free Software Foundation, Inc.
  *
  *  GRUB is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -106,7 +106,7 @@ void
 grub_cmp_init (void)
 {
   grub_register_command ("cmp", grub_cmd_cmp, GRUB_COMMAND_FLAG_BOTH,
-                        "cmp FILE1 FILE2", "Compare two files", 0);
+                        "cmp FILE1 FILE2", "Compare two files.", 0);
 }
 
 void
@@ -117,9 +117,9 @@ grub_cmp_fini (void)
 #else /* ! GRUB_UTIL */
 GRUB_MOD_INIT
 {
-  (void)mod;                   /* To stop warning. */
+  (void) mod;                  /* To stop warning. */
   grub_register_command ("cmp", grub_cmd_cmp, GRUB_COMMAND_FLAG_BOTH,
-                        "cmp FILE1 FILE2", "Compare two files", 0);
+                        "cmp FILE1 FILE2", "Compare two files.", 0);
 }
 
 GRUB_MOD_FINI
index 79b41a2371c009529fc4714d92e114875dfed6d1..6b46f2368364054fafe2ab6d9b7d036f236c072f 100644 (file)
@@ -45,7 +45,7 @@ grub_configfile_init (void)
 {
   grub_register_command ("configfile", grub_cmd_configfile,
                         GRUB_COMMAND_FLAG_BOTH, "configfile FILE",
-                        "Load config file", 0);
+                        "Load another config file.", 0);
 }
 
 void
@@ -56,10 +56,10 @@ grub_configfile_fini (void)
 #else /* ! GRUB_UTIL */
 GRUB_MOD_INIT
 {
-  (void)mod;                   /* To stop warning. */
+  (void) mod;                   /* To stop warning. */
   grub_register_command ("configfile", grub_cmd_configfile,
                         GRUB_COMMAND_FLAG_BOTH, "configfile FILE",
-                        "Load config file", 0);
+                        "Load another config file.", 0);
 }
 
 GRUB_MOD_FINI
index 87480dfeb0f8dd82b4129572a0b08788148d2bb4..cd937755111e626491531e100363e2f9d943e707 100644 (file)
@@ -99,7 +99,7 @@ void
 grub_help_init (void)
 {
   grub_register_command ("help", grub_cmd_help, GRUB_COMMAND_FLAG_CMDLINE,
-                        "help [PATTERN ...]", "Shows a help message", 0);
+                        "help [PATTERN ...]", "Show a help message.", 0);
 }
 
 void
@@ -112,7 +112,7 @@ GRUB_MOD_INIT
 {
   (void)mod;                   /* To stop warning. */
   grub_register_command ("help", grub_cmd_help, GRUB_COMMAND_FLAG_CMDLINE,
-                        "help [PATTERN ...]", "Shows a help message", 0);
+                        "help [PATTERN ...]", "Show a help message.", 0);
 }
 
 GRUB_MOD_FINI
index 4923676f74dc6a68643d64ca3ef8a0c1debf2507..c559ed3ad12719a594ece4c4e9a78c7a5759ace6 100644 (file)
@@ -25,7 +25,7 @@
 
 static const struct grub_arg_option options[] =
   {
-    {"no-apm", 'n', 0, "Don't use APM to halt the computer", 0, 0},
+    {"no-apm", 'n', 0, "do not use APM to halt the computer", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -63,7 +63,7 @@ GRUB_MOD_INIT
 {
   (void)mod;                   /* To stop warning. */
   grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
-                        "halt [OPTIONS...]",
+                        "halt [-n]",
                         "Halt the system, if possible using APM", options);
 }
 
index d9d68f38689c7d0d58e275573aac69db087e6652..27ed192ea79f86e32fa4df5b8c1b3f259447fa78 100644 (file)
@@ -40,7 +40,7 @@ void
 grub_reboot_init (void)
 {
   grub_register_command ("reboot", grub_cmd_reboot, GRUB_COMMAND_FLAG_BOTH,
-                        "reboot", "Reboot the computer", 0);
+                        "reboot", "Reboot the computer.", 0);
 }
 
 void
index 05f80efab2e5fe1de4da3600e090dfef9491b88e..e0be7cc3cf5863686aa44a9a1fc103888389e486 100644 (file)
@@ -33,9 +33,9 @@
 
 static const struct grub_arg_option options[] =
   {
-    {"long", 'l', 0, "Show a long list with more detailed information", 0, 0},
-    {"human-readable", 'h', 0, "Print sizes in a human readable format", 0, 0},
-    {"all", 'a', 0, "List all files", 0, 0},
+    {"long", 'l', 0, "show a long list with more detailed information", 0, 0},
+    {"human-readable", 'h', 0, "print sizes in a human readable format", 0, 0},
+    {"all", 'a', 0, "list all files", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -241,8 +241,8 @@ void
 grub_ls_init (void)
 {
   grub_register_command ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH,
-                        "ls [OPTIONS...] [DIR]",
-                        "List devices and files", options);
+                        "ls [-l|-h|-a] [FILE]",
+                        "List devices and files.", options);
 }
 
 void
@@ -255,8 +255,8 @@ GRUB_MOD_INIT
 {
   (void)mod;                   /* To stop warning. */
   grub_register_command ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH,
-                        "ls [OPTIONS...] [DIR]",
-                        "List devices and files", options);
+                        "ls [-l|-h|-a] [FILE]",
+                        "List devices and files.", options);
 }
 
 GRUB_MOD_FINI
index fa3d5222bea9a420f21cf46965532a706c0d17a0..ada10a752b957152b21c996fec5d5daeb1c5fb08 100644 (file)
@@ -38,8 +38,8 @@ static struct grub_loopback *loopback_list;
 
 static const struct grub_arg_option options[] =
   {
-    {"delete", 'd', 0, "Delete the loopback device entry", 0, 0},
-    {"partitions", 'p', 0, "Set that the drive has partitions to"
+    {"delete", 'd', 0, "delete the loopback device entry", 0, 0},
+    {"partitions", 'p', 0, "set that the drive has partitions to"
      " simulate a harddrive", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
@@ -245,7 +245,8 @@ void
 grub_loop_init (void)
 {
   grub_register_command ("loopback", grub_cmd_loopback, GRUB_COMMAND_FLAG_BOTH,
-                        "loopback [OPTIONS] DEVICENAME FILE", "Makes a device of a file", options);
+                        "loopback [-d|-p] DEVICENAME FILE",
+                        "Make a device of a file.", options);
   grub_disk_dev_register (&grub_loopback_dev);
 }
 
@@ -260,7 +261,8 @@ GRUB_MOD_INIT
 {
   (void)mod;                   /* To stop warning. */
   grub_register_command ("loopback", grub_cmd_loopback, GRUB_COMMAND_FLAG_BOTH,
-                        "loopback [OPTIONS] DEVICENAME FILE", "Makes a device of a file", options);
+                        "loopback [-d|-p] DEVICENAME FILE",
+                        "Make a device of a file.", options);
   grub_disk_dev_register (&grub_loopback_dev);
 }
 
index 9f9c6ce4ddd095d4ffdca35808a5fc882f8df291..22242b609023c9c46f814fa3f14d7927f032f0d2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2005  Free Software Foundation, 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
@@ -236,7 +236,8 @@ GRUB_MOD_INIT
 {
   (void) mod; /* Stop warning.  */
   grub_register_command ("font", font_command, GRUB_COMMAND_FLAG_BOTH,
-                        "font FILE...", "Specify a font file to display.", 0);
+                        "font FILE...",
+                        "Specify one or more font files to display.", 0);
 }
 
 GRUB_MOD_FINI
index 4bdad966dff2061b53c664fe5ca3fd29150b0274..ceb510c1e609b9256dfde5b324cb9140e9ef674b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2005  Free Software Foundation, Inc.
  *
  *  GRUB is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -49,8 +49,8 @@ typedef enum grub_key_type grub_arg_key_type_t;
 
 struct grub_arg_option
 {
-  char *longarg;
-  char shortarg;
+  const char *longarg;
+  int shortarg;
   int flags;
   char *doc;
   char *arg;
index 368f99e73c63c53700ff68eb30e237096c9f75db..64542827e8f5759b6b573b23003e4f39cac1f403 100644 (file)
@@ -25,7 +25,7 @@
 
 static const struct grub_arg_option options[] =
   {
-    {"force", 'f', 0, "Skip bootsector magic number test.", 0, 0},
+    {"force", 'f', 0, "skip bootsector magic number test", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -47,8 +47,8 @@ GRUB_MOD_INIT
   (void) mod; /* To stop warning.  */
   grub_register_command ("chainloader", chainloader_command,
                         GRUB_COMMAND_FLAG_BOTH,
-                        "chainloader [options] FILE",
-                        "Prepare to boot another boot loader", options);
+                        "chainloader [-f] FILE",
+                        "Prepare to boot another boot loader.", options);
 }
 
 GRUB_MOD_FINI
index 00e9cea9509368572f6c0932deb3499cbe9d14b2..6207513db0d4a5aba258fe02251a9a8ca61671e3 100644 (file)
@@ -1,7 +1,7 @@
 /* linux_normal.c - boot another boot loader */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *  Copyright (C) 2004,2005  Free Software Foundation, 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
@@ -46,12 +46,12 @@ GRUB_MOD_INIT
   grub_register_command ("linux", grub_normal_linux_command,
                         GRUB_COMMAND_FLAG_BOTH,
                         "linux FILE [ARGS...]",
-                        "Load linux", 0);
+                        "Load a linux kernel.", 0);
   
   grub_register_command ("initrd", grub_normal_initrd_command,
                         GRUB_COMMAND_FLAG_BOTH,
                         "initrd FILE",
-                        "Load initrd", 0);
+                        "Load an initrd.", 0);
 }
 
 GRUB_MOD_FINI
index 93c122942971b21f5651edbd2e3fae5c18050b09..9344b29960bcf4e9774a2b5937b21a814d198dca 100644 (file)
@@ -1,7 +1,7 @@
 /* multiboot_normal.c - boot another boot loader */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *  Copyright (C) 2004,2005  Free Software Foundation, 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
@@ -46,12 +46,12 @@ GRUB_MOD_INIT
   grub_register_command ("multiboot", grub_normal_cmd_multiboot,
                         GRUB_COMMAND_FLAG_BOTH | GRUB_COMMAND_FLAG_NO_ARG_PARSE,
                         "multiboot FILE [ARGS...]",
-                        "Load a multiboot kernel", 0);
+                        "Load a Multiboot kernel.", 0);
   
   grub_register_command ("module", grub_normal_cmd_module,
                         GRUB_COMMAND_FLAG_BOTH | GRUB_COMMAND_FLAG_NO_ARG_PARSE,
                         "module FILE [ARGS...]",
-                        "Load a multiboot module", 0);
+                        "Load a Multiboot module.", 0);
 }
 
 GRUB_MOD_FINI
index b834d31162a24996905cbb3c04a12b6830b0309f..49edad6dee84ada81d460e881038d9c6c49f1ba3 100644 (file)
@@ -1,7 +1,7 @@
 /* arg.c - argument parser */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003, 2004  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2004,2005  Free Software Foundation, Inc.
  *
  *  GRUB is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include "grub/arg.h"
-#include "grub/misc.h"
-#include "grub/mm.h"
-#include "grub/err.h"
-#include "grub/normal.h"
+#include <grub/arg.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/term.h>
+
+/* Built-in parser for default options.  */
+#define SHORT_ARG_HELP -100
+#define SHORT_ARG_USAGE        -101
 
-/* Build in parser for default options.  */
 static const struct grub_arg_option help_options[] =
   {
-    {"help", 'h', 0, "Display help", 0, ARG_TYPE_NONE},
-    {"usage", 'u', 0, "Show how to use this command", 0, ARG_TYPE_NONE},
+    {"help", SHORT_ARG_HELP, 0,
+     "display this help and exit", 0, ARG_TYPE_NONE},
+    {"usage", SHORT_ARG_USAGE, 0,
+     "display the usage of this command and exit", 0, ARG_TYPE_NONE},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -51,8 +57,23 @@ find_short (const struct grub_arg_option *options, char c)
 
   if (options)
     found = fnd_short (options);
+  
   if (! found)
-    found = fnd_short (help_options);
+    {
+      switch (c)
+       {
+       case 'h':
+         found = (struct grub_arg_option *) help_options;
+         break;
+
+       case 'u':
+         found = (struct grub_arg_option *) (help_options + 1);
+         break;
+
+       default:
+         break;
+       }
+    }
     
   return found;
 }
@@ -80,7 +101,7 @@ find_long (const struct grub_arg_option *options, char *s)
     {
       while (opt->doc)
        {
-         if (opt->longarg && !grub_strcmp (opt->longarg, s))
+         if (opt->longarg && ! grub_strcmp (opt->longarg, s))
            return (struct grub_arg_option *) opt;
          opt++;
        }
@@ -89,7 +110,8 @@ find_long (const struct grub_arg_option *options, char *s)
 
   if (options)
     found = fnd_long (options);
-  if (!found)
+  
+  if (! found)
     found = fnd_long (help_options);
     
   return found;
@@ -104,24 +126,55 @@ show_usage (grub_command_t cmd)
 void
 grub_arg_show_help (grub_command_t cmd)
 {
-  static void showargs (const struct grub_arg_option *opt)
+  auto void showargs (const struct grub_arg_option *opt);
+  int h_is_used = 0;
+  int u_is_used = 0;
+  
+  auto void showargs (const struct grub_arg_option *opt)
     {
       for (; opt->doc; opt++)
        {
+         int spacing = 20;
+         
          if (opt->shortarg && grub_isgraph (opt->shortarg))
            grub_printf ("-%c%c ", opt->shortarg, opt->longarg ? ',':' ');
+         else if (opt->shortarg == SHORT_ARG_HELP && ! h_is_used)
+           grub_printf ("-h, ");
+         else if (opt->shortarg == SHORT_ARG_USAGE && ! u_is_used)
+           grub_printf ("-u, ");
          else
            grub_printf ("    ");
+         
          if (opt->longarg)
            {
              grub_printf ("--%s", opt->longarg);
+             spacing -= grub_strlen (opt->longarg);
+             
              if (opt->arg)
-               grub_printf ("=%s", opt->arg);
+               {
+                 grub_printf ("=%s", opt->arg);
+                 spacing -= grub_strlen (opt->arg) + 1;
+               }
            }
-         else
-           grub_printf ("\t");
 
-         grub_printf ("\t\t%s\n", opt->doc);
+         while (spacing-- > 0)
+           grub_putchar (' ');
+
+         grub_printf ("%s\n", opt->doc);
+
+         switch (opt->shortarg)
+           {
+           case 'h':
+             h_is_used = 1;
+             break;
+
+           case 'u':
+             u_is_used = 1;
+             break;
+
+           default:
+             break;
+           }
        }
     }  
 
@@ -141,11 +194,11 @@ parse_option (grub_command_t cmd, int key, char *arg, struct grub_arg_list *usr)
 {
   switch (key)
     {
-    case 'h':
+    case SHORT_ARG_HELP:
       grub_arg_show_help (cmd);
       return -1;
       
-    case 'u':
+    case SHORT_ARG_USAGE:
       show_usage (cmd);
       return -1;
 
@@ -221,7 +274,7 @@ grub_arg_parse (grub_command_t cmd, int argc, char **argv,
          while (1)
            {
              opt = find_short (cmd->options, *curshort);
-             if (!opt)
+             if (! opt)
                {
                  grub_error (GRUB_ERR_BAD_ARGUMENT,
                              "Unknown argument `-%c'\n", *curshort);
@@ -274,7 +327,7 @@ grub_arg_parse (grub_command_t cmd, int argc, char **argv,
          arg = longarg;
 
          opt = find_long (cmd->options, arg + 2);
-         if (!opt)
+         if (! opt)
            {
              grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown argument `%s'\n", arg);
              goto fail;
@@ -282,9 +335,9 @@ grub_arg_parse (grub_command_t cmd, int argc, char **argv,
        }
 
       if (! (opt->type == ARG_TYPE_NONE 
-            || (!option && (opt->flags & GRUB_ARG_OPTION_OPTIONAL))))
+            || (! option && (opt->flags & GRUB_ARG_OPTION_OPTIONAL))))
        {
-         if (!option)
+         if (! option)
            {
              grub_error (GRUB_ERR_BAD_ARGUMENT, 
                          "Missing mandatory option for `%s'\n", opt->longarg);
index f3af5f4ca3ef69bcd5d8ab4beb7dc844e49aade3..90b2e46cd48c9e805ca00225c7c0aa09482b3def 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2005  Free Software Foundation, 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
@@ -382,16 +382,19 @@ grub_command_init (void)
   grub_register_command ("title", 0, GRUB_COMMAND_FLAG_TITLE, 0, 0, 0);
 
   grub_register_command ("rescue", rescue_command, GRUB_COMMAND_FLAG_BOTH,
-                        "rescue", "Enter into the rescue mode.", 0);
+                        "rescue", "Go back to the rescue mode.", 0);
 
   grub_register_command ("set", set_command, GRUB_COMMAND_FLAG_BOTH,
-                        "set [ENVVAR=VALUE]", "Set an environment variable.", 0);
+                        "set [ENVVAR=VALUE]",
+                        "Set an environment variable.", 0);
 
   grub_register_command ("unset", unset_command, GRUB_COMMAND_FLAG_BOTH,
                         "unset ENVVAR", "Remove an environment variable.", 0);
 
   grub_register_command ("insmod", insmod_command, GRUB_COMMAND_FLAG_BOTH,
-                        "insmod MODULE|FILE", "Insert a module.", 0);
+                        "insmod MODULE",
+                        "Insert a module. The argument can be a file or a module name.",
+                        0);
 
   grub_register_command ("rmmod", rmmod_command, GRUB_COMMAND_FLAG_BOTH,
                         "rmmod MODULE", "Remove a module.", 0);