From fe3244ca9c8c9a38ea700851e36667b1015d11e6 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Fri, 2 Aug 2013 14:27:44 -0400 Subject: Extra argument parsing into rcm.sh Pull the `-V`, `-v`, `-q`, `-t`, and `-d` out into the `handle_common_flags` and `handle_metadata_flags` functions, shared between the different programs. --- bin/lsrc | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) (limited to 'bin/lsrc') diff --git a/bin/lsrc b/bin/lsrc index 766aa2f..d5e335e 100755 --- a/bin/lsrc +++ b/bin/lsrc @@ -1,13 +1,7 @@ #!/bin/sh -#set -x - -DEST_DIR=$HOME -DEFAULT_DOTFILES_DIR=$HOME/.dotfiles -HOSTNAME=`hostname -s` -DEBUG=: -PRINT=echo -VERBOSE=: +: ${RCM_LIB:=`dirname $0`/../share/rcm} +. $RCM_LIB/rcm.sh pushdir() { DIR_STACK="$DIR_STACK:$PWD/$1" @@ -91,7 +85,8 @@ handle_command_line() { arg_tags="" verbosity=0 version=0 - dotfiles_dirs= + dotfiles_dirs="" + while getopts Vqvt:d: opt; do case "$opt" in t) arg_tags="$arg_tags $OPTARG";; @@ -103,35 +98,8 @@ handle_command_line() { done shift $(($OPTIND-1)) - if [ $version -eq 1 ]; then - version rcup - exit 0 - elif [ $verbosity -ge 2 ]; then - DEBUG=echo - VERBOSE=echo - PRINT=echo - elif [ $verbosity -eq 1 ]; then - DEBUG=: - VERBOSE=echo - PRINT=echo - elif [ $verbosity -eq 0 ]; then - DEBUG=: - VERBOSE=: - PRINT=echo - else - DEBUG=: - VERBOSE=: - PRINT=: - fi - - if [ "x$arg_tags" != "x" ]; then - TAGS=$arg_tags - fi - - if [ "x$dotfiles_dirs" != "x" ]; then - DOTFILES_DIRS=$dotfiles_dirs - fi - + handle_common_flags lsrc $version $verbosity + handle_metadata_flags $arg_tags $dotfiles_dirs FILES=$@ } @@ -141,7 +109,6 @@ if [ -e $HOME/.rcrc ]; then . $HOME/.rcrc fi -. `dirname $0`/../share/rcm/rcm.sh handle_command_line $* if [ "x$DOTFILES_DIRS" = "x" ]; then -- cgit v1.2.3