Use descriptive parameter names for Usage()

This commit is contained in:
Raphaël Hertzog 2020-04-23 16:38:59 +02:00
parent b3bba232ac
commit 4c75f80e67
18 changed files with 34 additions and 25 deletions

View File

@ -25,7 +25,7 @@ Arguments frontend "${@}"
eval set -- "${REMAINING_ARGS}" eval set -- "${REMAINING_ARGS}"
if [ -z "${1}" ]; then if [ -z "${1}" ]; then
Usage 1 Usage --fail
fi fi
COMMAND="${1}" COMMAND="${1}"

View File

@ -127,7 +127,7 @@ Arguments ()
fi fi
exit 0 exit 0
elif [ "${IS_FRONTEND}" = "true" ]; then elif [ "${IS_FRONTEND}" = "true" ]; then
Usage 0 Usage --exit
fi fi
;; ;;
@ -137,7 +137,7 @@ Arguments ()
;; ;;
-u|--usage) -u|--usage)
Usage 0 Usage --exit
shift shift
;; ;;

View File

@ -11,10 +11,6 @@
Usage () Usage ()
{ {
if [ -z "${1}" ]; then
Echo_error "Usage() requires an exit code"
fi
echo "${PROGRAM_NAME} - ${DESCRIPTION}" echo "${PROGRAM_NAME} - ${DESCRIPTION}"
printf "\nUsage:\n\n" printf "\nUsage:\n\n"
@ -29,5 +25,18 @@ Usage ()
echo echo
echo "Try \"${PROGRAM} --help\" for more information." echo "Try \"${PROGRAM} --help\" for more information."
exit $1 case $1 in
--fail)
exit 1
;;
--exit)
exit 0
;;
"")
:
;;
*)
Echo_error "Unexpected parameter to Usage(): $1"
;;
esac
} }

View File

@ -217,6 +217,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -23,7 +23,7 @@ _ACTION="${2}"
shift 2 shift 2
if ! In_list "${_PASS}" "binary" "chroot" "source"; then if ! In_list "${_PASS}" "binary" "chroot" "source"; then
Usage 1 Usage --fail
fi fi
# Processing arguments and configuration files # Processing arguments and configuration files
@ -441,6 +441,6 @@ case "${_ACTION}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -67,6 +67,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -63,6 +63,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -84,6 +84,6 @@ EOF
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -77,6 +77,6 @@ EOF
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -83,6 +83,6 @@ EOF
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -67,6 +67,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -95,6 +95,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -64,6 +64,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -61,6 +61,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -73,6 +73,6 @@ EOF
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -66,6 +66,6 @@ case "${1}" in
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac

View File

@ -144,7 +144,7 @@ do
;; ;;
-u|--usage) -u|--usage)
Usage 0 Usage --exit
;; ;;
-v|--version) -v|--version)
@ -153,7 +153,7 @@ do
;; ;;
*) *)
Usage 1 Usage --fail
;; ;;
esac esac
done done

View File

@ -294,7 +294,7 @@ Local_arguments ()
;; ;;
-u|--usage) -u|--usage)
Usage 0 Usage --exit
shift shift
;; ;;