]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[set-default-theme] Add --help option
authorAdrian Glaubitz <glaubitz@physik.fu-berlin.de>
Sat, 5 Dec 2009 17:05:10 +0000 (12:05 -0500)
committerRay Strode <rstrode@redhat.com>
Sat, 5 Dec 2009 17:08:01 +0000 (12:08 -0500)
When running new, unfamiliar commands I usually invoke them with
--help to see what options they have. For plymouth-set-default-theme,
there is no --help option which I find a bit confusing, especially
since the usage is not straight-forward.

There is now an additional function "show_help" which displays an
help output when invoking plymouth-set-default-theme with --help.

scripts/plymouth-set-default-theme.in

index fa43901c52a29546838da1eb6dba82dee96a22f0..195940dfd3481c626d33f27617f30dc2b342d1bd 100755 (executable)
@@ -13,9 +13,24 @@ if [ -z "$PLYMOUTH_PLUGIN_PATH" ]; then
     fi
 fi
 
+
 function usage ()
 {
-  echo "usage: plymouth-set-default-theme { --list | --reset | <theme-name> [ --rebuild-initrd ] }"
+  echo "usage: plymouth-set-default-theme { --list | --reset | <theme-name> [ --rebuild-initrd ] | --help }"
+}
+
+function show_help() {
+  cat <<EOF
+
+    ${0##*/} [opt]
+
+     --help             show this help message
+     --list             show available themes
+     --reset            reset to default theme
+     --rebuild-initrd   rebuild initrd (necessary after changing theme)
+     <theme-name>       name of new theme to use (see --list for available themes)
+
+EOF
 }
 
 function list_themes ()
@@ -39,6 +54,7 @@ function get_default_theme ()
 DO_RESET=0
 DO_INITRD_REBUILD=0
 DO_LIST=0
+DO_HELP=0
 THEME_NAME=""
 while [ $# -gt 0 ]; do
         case "$1" in
@@ -79,6 +95,10 @@ while [ $# -gt 0 ]; do
                 DO_RESET=1
         ;;
 
+       --help)
+               DO_HELP=1
+       ;;
+
         *)
                 if [ -n "$THEME_NAME" ]; then
                         echo "You can only specify one theme at a time" > /dev/stderr
@@ -104,6 +124,11 @@ while [ $# -gt 0 ]; do
   shift
 done
 
+if [ $DO_HELP -eq 1 ]; then
+        show_help
+       exit $?
+fi
+
 if [ $DO_LIST -ne 0 ]; then
         list_themes
         exit $?