]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix --help formatting.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 7 Apr 2012 17:49:25 +0000 (19:49 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 7 Apr 2012 17:49:25 +0000 (19:49 +0200)
* util/grub-mkconfig_lib.in (print_option_help): New function.
(grub_fmt): Likewise.
* util/grub-install.in: Use print_option_help and grub_fmt.
* util/grub-kbdcomp.in: Likewise.
* util/grub-mkconfig.in: Likewise.
* util/grub-mknetdir.in: Likewise.
* util/grub-mkrescue.in: Likewise.
* util/grub-mkstandalone.in: Likewise.
* util/grub-reboot.in: Likewise.
* util/grub-set-default.in: Likewise.
* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.

ChangeLog
util/grub-install.in
util/grub-kbdcomp.in
util/grub-mkconfig.in
util/grub-mkconfig_lib.in
util/grub-mknetdir.in
util/grub-mkrescue.in
util/grub-mkstandalone.in
util/grub-reboot.in
util/grub-set-default.in
util/powerpc/ieee1275/grub-mkrescue.in

index 88914fbf55677000bdd9dacd9208f184ac18e8c8..ebafe109ca83e7d757684f1ac7bd724db0de2fe9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2012-04-07  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Fix --help formatting.
+
+       * util/grub-mkconfig_lib.in (print_option_help): New function.
+       (grub_fmt): Likewise.
+       * util/grub-install.in: Use print_option_help and grub_fmt.
+       * util/grub-kbdcomp.in: Likewise.
+       * util/grub-mkconfig.in: Likewise.
+       * util/grub-mknetdir.in: Likewise.
+       * util/grub-mkrescue.in: Likewise.
+       * util/grub-mkstandalone.in: Likewise.
+       * util/grub-reboot.in: Likewise.
+       * util/grub-set-default.in: Likewise.
+       * util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
+
 2012-04-07  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * linguas.sh: Remove autogenerated *.po.
index 92288950fe7391c5c959f714d2005bbd691b8d7d..8d4b55e58e2ff7037145f40d7e97f400b48eae9a 100644 (file)
@@ -87,30 +87,30 @@ usage () {
     echo
     gettext "Install GRUB on your drive." ; echo
     echo
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
-    printf "  --modules=%-14s%s\n" "$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+    print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
     dirmsg="$(gettext_printf "install GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
-    printf "  --boot-directory=%-7s%s\n" "$(gettext "DIR")" "$dirmsg"
+    print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
     # TRANSLATORS: "TARGET" as in "target platform".
     target_trans="$(gettext "TARGET")"
     # TRANSLATORS: "current" refers to the platform user's currently running on
-    printf "  --target=%-15s%s\n" "$target_trans" "$(gettext "install GRUB for TARGET platform [default=current]")"
-    printf "  --directory=%-12s%s\n" "$(gettext "DIR")" "$(gettext "use GRUB images from DIR. Takes precedence over target")"
-    printf "  --grub-setup=%-11s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-setup")"
-    printf "  --grub-mkimage=%-9s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
-    printf "  --grub-mkrelpath=%-7s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
-    printf "  --grub-probe=%-11s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-probe")"
+    print_option_help "--target=$target_trans" "$(gettext "install GRUB for TARGET platform [default=current]")"
+    print_option_help "--directory=$(gettext "DIR")" "$(gettext "use GRUB images from DIR. Takes precedence over target")"
+    print_option_help "--grub-setup=$(gettext "FILE")" "$(gettext "use FILE as grub-setup")"
+    print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
+    print_option_help "--grub-mkrelpath=$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
+    print_option_help "--grub-probe=$(gettext "FILE")" "$(gettext "use FILE as grub-probe")"
     # TRANSLATORS: "may break" doesn't just mean that option wouldn't have any
     # effect but that it will make the resulting install unbootable from HDD.
-    printf "  --allow-floppy          %s\n" "$(gettext "make the drive also bootable as floppy (default for fdX devices). May break on some BIOSes.")"
-    printf "  --recheck               %s\n" "$(gettext "delete device map if it already exists")"
-    printf "  --force                 %s\n" "$(gettext "install even if problems are detected")"
-    printf "  --force-file-id         %s\n" "$(gettext "use identifier file even if UUID is available")"
-    printf "  --disk-module=%-10s%s\n" "$(gettext "MODULE")" "$(gettext "disk module to use (biosdisk or native). This option is only available on BIOS target.")"
-    printf "  --no-nvram              %s\n" "$(gettext "don't update the \`boot-device' NVRAM variable. This option is only available on IEEE1275 targets.")"
-    printf "  --removable             %s\n" "$(gettext "the installation device is removable. This option is only available on EFI.")"
-    printf "  --bootloader-id=%-8s%s\n" "$(gettext "ID")" "$(gettext "the ID of bootloader. This option is only available on EFI.")"
+    print_option_help "--allow-floppy" "$(gettext "make the drive also bootable as floppy (default for fdX devices). May break on some BIOSes.")"
+    print_option_help "--recheck" "$(gettext "delete device map if it already exists")"
+    print_option_help "--force" "$(gettext "install even if problems are detected")"
+    print_option_help "--force-file-id" "$(gettext "use identifier file even if UUID is available")"
+    print_option_help "--disk-module=$(gettext "MODULE")" "$(gettext "disk module to use (biosdisk or native). This option is only available on BIOS target.")"
+    print_option_help "--no-nvram" "$(gettext "don't update the \`boot-device' NVRAM variable. This option is only available on IEEE1275 targets.")"
+    print_option_help  "--removable" "$(gettext "the installation device is removable. This option is only available on EFI.")"
+    print_option_help  "--bootloader-id=$(gettext "ID")" "$(gettext "the ID of bootloader. This option is only available on EFI.")"
 echo
 gettext "INSTALL_DEVICE must be system device filename.";echo
 echo
index 99c07656f9a6615bce5da60085f2312bd93764d6..29f045689f5ff3fabc56c12b18884377ff0f1e64 100644 (file)
@@ -26,9 +26,9 @@ usage () {
     gettext_printf "Usage: %s -o OUTPUT CKBMAP_ARGUMENTS...\n" "$self"
     gettext "Make GRUB keyboard layout file."; echo
     echo
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
-    printf "  -o, --output=%-11s%s\n" "$(gettext FILE)" "$(gettext "save output in FILE [required]")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+    print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")"
     echo
     gettext_printf "%s generates a keyboard layout for GRUB using ckbcomp\n" "$self"
     echo
index df3b7330ab7d09bd929d06a50fdfe1811bec682e..516be863dcfec61666d18cc8f02b7383ba01cbfb 100644 (file)
@@ -54,9 +54,9 @@ usage () {
     gettext_printf "Usage: %s [OPTION]\n" "$self"
     gettext "Generate a grub config file"; echo
     echo
-    printf "  -o, --output=%-11s%s\n" "$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
+    print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
     echo
     gettext "Report bugs to <bug-grub@gnu.org>."; echo
 }
index 34c47fb173ea497e14f31c5c289505c23a4ce55d..1227154482dd0e98d16466ea408432b32c898679 100644 (file)
@@ -286,3 +286,65 @@ uses_abstraction () {
   done
   return 1
 }
+
+print_option_help () {
+  if test x$print_option_help_wc = x; then
+      if wc -L < /dev/null > /dev/null; then
+         print_option_help_wc=-L
+      elif wc -m < /dev/null > /dev/null; then
+         print_option_help_wc=-m
+      else
+         print_option_help_wc=-b
+      fi
+  fi
+  if test x$grub_have_fmt = x; then
+      if fmt -w 40 < /dev/null > /dev/null; then
+         grub_have_fmt=y;
+      else
+         grub_have_fmt=n;
+      fi
+  fi
+  print_option_help_lead="  $1"
+  print_option_help_lspace="$(echo "$print_option_help_lead" | wc $print_option_help_wc)"
+  print_option_help_fill="$((26 - print_option_help_lspace))"
+  echo -n "$print_option_help_lead"
+  if test $print_option_help_fill -le 0; then
+      print_option_help_nl=y
+      echo
+  else
+      print_option_help_i=0;
+      while test $print_option_help_i -lt $print_option_help_fill; do
+         echo -n " "
+         print_option_help_i=$((print_option_help_i+1))
+      done
+      print_option_help_nl=n
+  fi
+  if test x$grub_have_fmt = xy; then
+      print_option_help_split="$(echo "$2" | fmt -w 50)"
+  else
+      print_option_help_split="$2"
+  fi
+  if test x$print_option_help_nl = xy; then
+      echo "$print_option_help_split" | awk \
+         '{ print "                          " $0; }'
+  else
+      echo "$print_option_help_split" | awk 'BEGIN   { n = 0 }
+  { if (n == 1) print "                          " $0; else print $0; n = 1 ; }'
+  fi
+}
+
+grub_fmt () {
+  if test x$grub_have_fmt = x; then
+      if fmt -w 40 < /dev/null > /dev/null; then
+         grub_have_fmt=y;
+      else
+         grub_have_fmt=n;
+      fi
+  fi
+
+  if test x$grub_have_fmt = xy; then
+      fmt
+  else
+      cat
+  fi
+}
index 652bc4c72a9144f5c716f0c07cd12f449dcaba6b..7042ec62b81387995a73872329fe6614cf395564 100644 (file)
@@ -64,12 +64,12 @@ usage () {
     gettext_printf "Usage: %s [OPTION]\n" "$self"
     gettext; echo "Install GRUB on your drive."; echo
     echo
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
-    printf "  --modules=%-14s%s\n" "$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
-    printf "  --net-directory=%-8s%s\n" "$(gettext "DIR")" "$(gettext "root directory of TFTP server")"
-    printf "  --subdir=%-15s%s\n" "$(gettext "DIR")" "$(gettext "relative subdirectory on network server")"
-    printf "  --grub-mkimage=%-9s%s" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+    print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
+    print_option_help "--net-directory=$(gettext "DIR")" "$(gettext "root directory of TFTP server")"
+    print_option_help "--subdir=$(gettext "DIR")" "$(gettext "relative subdirectory on network server")"
+    print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
     echo
     gettext_printf "%s copies GRUB images into net_directory/subdir/target_cpu-platform\n" "$self" 
     echo
index bd5250bf7cd0df5cb379a994557213d7bf392bfd..491aec7df9f19f047d290dfa3222a153f4187d76 100644 (file)
@@ -62,16 +62,16 @@ usage () {
     gettext "Make GRUB CD-ROM, disk, pendrive and floppy bootable image."; echo
     echo
     filetrans="$(gettext FILE)"
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
-    printf "  -o, --output=%-11s%s\n" "$filetrans" "$(gettext "save output in FILE [required]")"
-    printf "  --modules=%-14s%s\n" "$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
-    printf "  --rom-directory=%-8s%s\n" "$(gettext "DIR")" "$(gettext "save ROM images in DIR [optional]")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+    print_option_help "-o, --output=$filetrans" "$(gettext "save output in FILE [required]")"
+    print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
+    print_option_help "--rom-directory=$(gettext "DIR")" "$(gettext "save ROM images in DIR [optional]")"
     # TRANSLATORS: xorriso is a program for creating ISOs and burning CDs
-    printf "  --xorriso=%-14s%s\n" "$filetrans" "$(gettext "use FILE as xorriso [optional]")"
-    printf "  --grub-mkimage=%-9s%s\n" "$filetrans" "$(gettext "use FILE as grub-mkimage")"
+    print_option_help "--xorriso=$filetrans" "$(gettext "use FILE as xorriso [optional]")"
+    print_option_help "--grub-mkimage=$filetrans" "$(gettext "use FILE as grub-mkimage")"
     echo
-    gettext_printf "%s generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of \`%s'\n" "xorriso -as mkisofs -help" "$self"
+    gettext_printf "%s generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of \`%s'\n" "xorriso -as mkisofs -help" "$self" | grub_fmt
     echo
     gettext "Option -- switches to native xorriso command mode."; echo
     echo
index a733dd50e1909dcdcb50acec13b118dc77534016..87a3b42d54e6ab55c336a56427c076eae5ba5f89 100644 (file)
@@ -55,19 +55,18 @@ usage () {
     gettext_printf "Usage: %s [OPTION] SOURCE...\n" "$self"
     gettext "Generate a standalone image (containing all modules) in the selected format"
     echo
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
-    printf "  -o, --output=%-11s%s\n" "$(gettext FILE)" "$(gettext "save output in FILE [required]")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+    print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")"
     # TRANSLATORS: platform here isn't identifier. It can be translated.
     dir_msg="$(gettext_printf "use images and modules under DIR [default=%s/<platform>]" "${libdir}/@PACKAGE@")"
-    printf "  -d, --directory=%-8s%s\n" \
-       "DIR" "$dir_msg"
-    printf     "  -O, --format=%-11s%s" "$(gettext "FORMAT")" "$(gettext "generate an image in FORMAT")"; echo
-    printf "                          %s %s\n" "$(gettext "available formats:")" "$formats"
+    print_option_help "-d, --directory=$(gettext "DIR")" "$dir_msg"
+    print_option_help "-O, --format=$(gettext "FORMAT")" "$(gettext "generate an image in FORMAT")"; echo
+    print_option_help "" "$(gettext "available formats:") $formats"
     echo
-    printf     "  -C, --compression=(xz|none|auto)  %s\n" "$(gettext "choose the compression to use")"
-    printf "  --modules=%-14s%s\n" "$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
-    printf "  --grub-mkimage=%-9s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
+    print_option_help "-C, --compression=(xz|none|auto)" "$(gettext "choose the compression to use")"
+    print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
+    print_option_help  "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
     echo
     gettext "Report bugs to <bug-grub@gnu.org>."; echo
 }
index 87d77724eca028d0cc3369d5ccd20d62a88fbb1c..93dbe6cdcb0435350331b8eadbe4cb7831277511 100644 (file)
@@ -48,10 +48,10 @@ usage () {
     gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
     gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
     echo
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
     dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
-    printf "  --boot-directory=%-7s%s\n" "$(gettext "DIR")" "$dirmsg"
+    print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
     echo
     gettext "MENU_ENTRY is a number, a menu item title or a menu item identifier."; echo
     echo
index 7fedb594123f38ec5c49bf746bc4438865312e50..3d890be403b51180e4b1284df3ebb749aa8a9b3d 100644 (file)
@@ -48,10 +48,10 @@ usage () {
     gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
     gettext "Set the default boot menu entry for GRUB."; echo
     echo
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
     dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
-    printf "  --boot-directory=%-7s%s\n" "$(gettext "DIR")" "$dirmsg"
+    print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
     echo
     gettext "MENU_ENTRY is a number, a menu item title or a menu item identifier."; echo
     echo
index a573db70ca2258adfe04924446a9e486d1bf8006..ec7a1391faf675b48be909dcc07d95ffde3970b5 100644 (file)
@@ -49,12 +49,12 @@ usage () {
     gettext_printf "Usage: %s [OPTION] SOURCE...\n" "$self"
     gettext "Make GRUB CD-ROM, disk, pendrive and floppy bootable image."; echo
     echo
-    printf "  -h, --help              %s\n" "$(gettext "print this message and exit")"
-    printf "  -v, --version           %s\n" "$(gettext "print the version information and exit")"
-    printf "  --modules=%-14s%s\n" "$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
-    printf "  --grub-mkimage=%-9s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
+    print_option_help "-h, --help" "$(gettext "print this message and exit")"
+    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+    print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
+    print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
     echo
-    gettext_printf "%s generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of \`%s'\n" "genisoimage -help" "$self"
+    gettext_printf "%s generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of \`%s'\n" "genisoimage -help" "$self" | grub_fmt
     echo
     gettext "Report bugs to <bug-grub@gnu.org>."; echo
 }