From 6d0cc62494d23baad1ba015cb9dc01af4632102b Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Fri, 16 Aug 2013 18:05:55 +0200 Subject: Add -h for lsrc, mkrc, rcdn, rcup Quick usage summaries for the four commands. --- bin/lsrc | 12 +++++++++++- bin/mkrc | 15 ++++++++++++--- bin/rcdn | 12 +++++++++++- bin/rcup | 12 +++++++++++- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/bin/lsrc b/bin/lsrc index 1ea2e2c..6f719e3 100755 --- a/bin/lsrc +++ b/bin/lsrc @@ -195,6 +195,15 @@ is_excluded() { return 1 } +show_help() { + local exit_code=${1:-0} + + $PRINT "Usage: lsrc [-FVqvh] [-I EXCL_PAT] [-x EXCL_PAT] [-t TAG] [-d DOT_DIR]" + $PRINT "see lsrc(1) and rcm(5) for more details" + + exit $exit_code +} + handle_command_line() { local arg_tags= local verbosity=0 @@ -204,9 +213,10 @@ handle_command_line() { local excludes= local includes= - while getopts FVqvI:x:t:d: opt; do + while getopts FVqvhI:x:t:d: opt; do case "$opt" in F) show_sigils=1;; + h) show_help ;; I) includes="$includes $OPTARG";; t) arg_tags="$arg_tags $OPTARG";; v) verbosity=$(($verbosity + 1));; diff --git a/bin/mkrc b/bin/mkrc index 8cd2bd0..113c079 100755 --- a/bin/mkrc +++ b/bin/mkrc @@ -22,9 +22,17 @@ if [ -e $HOME/.rcrc ]; then . $HOME/.rcrc fi +show_help() { + local exit_code=${1:-0} + + $PRINT "Usage: mkrc [-hvqo] [-t TAG] [-d DIR] FILES ..." + $PRINT "see mkrc(1) and rcm(5) for more details" + + exit $exit_code +} + if [ $# -eq 0 ]; then - echo "Usage: mkrc [-vqo] [-t tag] [-d dir] files ..." - exit 1 + show_help 1 fi for DOTFILES_DIR in $DOTFILES_DIRS $DEFAULT_DOTFILES_DIR; do @@ -37,9 +45,10 @@ in_host=0 version=0 always_copy=0 -while getopts CVvqot:d: opt; do +while getopts ChVvqot:d: opt; do case "$opt" in C) always_copy=1 ;; + h) show_help ;; t) tag=$OPTARG ;; v) verbosity=$(($verbosity + 1)) ;; q) verbosity=$(($verbosity - 1)) ;; diff --git a/bin/rcdn b/bin/rcdn index 2c52be4..1f44fa2 100755 --- a/bin/rcdn +++ b/bin/rcdn @@ -18,6 +18,15 @@ remove_link() { fi } +show_help() { + local exit_code=${1:-0} + + $PRINT "Usage: rcdn [-Vqvh] [-I EXCL_PAT] [-x EXCL_PAT] [-t TAG] [-d DOT_DIR]" + $PRINT "see rcdn(1) and rcm(5) for more details" + + exit $exit_code +} + handle_command_line() { local arg_tags= local verbosity=0 @@ -28,8 +37,9 @@ handle_command_line() { local excludes= local includes= - while getopts VqvI:x:t:d: opt; do + while getopts VqvhI:x:t:d: opt; do case "$opt" in + h) show_help ;; I) includes="$includes $OPTARG";; k) run_hooks=1 ;; K) run_hooks=0 ;; diff --git a/bin/rcup b/bin/rcup index 2dff893..9dd7ca9 100755 --- a/bin/rcup +++ b/bin/rcup @@ -85,6 +85,15 @@ handle_file() { fi } +show_help() { + local exit_code=${1:-0} + + $PRINT "Usage: rcup [-CVqvfhikK] [-I EXCL_PAT] [-x EXCL_PAT] [-t TAG] [-d DOT_DIR]" + $PRINT "see rcup(1) and rcm(5) for more details" + + exit $exit_code +} + handle_command_line() { local arg_tags= local verbosity=0 @@ -97,11 +106,12 @@ handle_command_line() { local always_copy=0 REPLACE_ALL=0 - while getopts CVqvfikKI:x:t:d: opt; do + while getopts CVqvfhikKI:x:t:d: opt; do case "$opt" in C) always_copy=1 ;; d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;; f) REPLACE_ALL=1 ;; + h) show_help ;; i) REPLACE_ALL=0 ;; I) includes="$includes $OPTARG" ;; k) run_hooks=1 ;; -- cgit v1.2.3