~dricottone/my-utils

bc266dc94a50fa474b44aee7eb1e1a92ae34ca35 — Dominic Ricottone 2 years ago 437e26d
Use standard arg parser
3 files changed, 5 insertions(+), 74 deletions(-)

M core/debom
M core/myparse.bash
M core/rebom
M core/debom => core/debom +1 -35
@@ 13,41 13,7 @@ read -r -d '' help_message <<-EOF
EOF

source /usr/local/lib/mylib.bash

positional=()
quiet=0
verbose=0
while [[ $# -gt 0 ]]; do
  case "$1" in

  -h|--help)
    help_msg
    shift
    ;;

  -q|--quiet)
    debug_msg "Setting quiet option to 1 (was ${quiet})"
    quiet=1
    shift
    ;;

  -v|--verbose)
    debug_msg "Setting verbose option to 1 (was ${verbose})"
    verbose=1
    shift
    ;;

  -V|--version)
    version_msg
    ;;

  *)
    debug_msg "Argument '${1}' added to positional array"
    positional+=("$1")
    shift
    ;;
  esac
done
. /usr/local/lib/myparse.bash

# error if no filenames given
if [[ ${#positional[@]} -eq 0 ]]; then

M core/myparse.bash => core/myparse.bash +3 -3
@@ 9,7 9,7 @@ quiet=0
verbose=0

while [[ $# -gt 0 ]]; do
  case $1 in
  case "$1" in

  -h|--help)
    help_msg


@@ 17,13 17,13 @@ while [[ $# -gt 0 ]]; do
    ;;

  -q|--quiet)
    debug_msg "Setting QUIET option to 1 (was ${quiet})"
    debug_msg "Setting quiet option to 1 (was ${quiet})"
    quiet=1
    shift
    ;;

  -v|--verbose)
    debug_msg "Setting VERBOSE option to 1 (was ${verbose})"
    debug_msg "Setting verbose option to 1 (was ${verbose})"
    verbose=1
    shift
    ;;

M core/rebom => core/rebom +1 -36
@@ 13,42 13,7 @@ read -r -d '' help_message <<-EOF
EOF

source /usr/local/lib/mylib.bash

positional=()
quiet=0
verbose=0
while [[ $# -gt 0 ]]; do
  case "$1" in

  -h|--help)
    help_msg
    shift
    ;;

  -q|--quiet)
    debug_msg "Setting quiet option to 1 (was ${quiet})"
    quiet=1
    shift
    ;;

  -v|--verbose)
    debug_msg "Setting verbose option to 1 (was ${verbose})"
    verbose=1
    shift
    ;;

  -V|--version)
    version_msg
    shift
    ;;

  *)
    debug_msg "Argument '${1}' added to positional array"
    positional+=("$1")
    shift
    ;;
  esac
done
. /usr/local/lib/myparse.bash

# error if no filenames given
if [[ ${#positional[@]} -eq 0 ]]; then