mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2025-01-12 07:22:35 +00:00
61 lines
1.9 KiB
Bash
61 lines
1.9 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
set -o pipefail
|
||
|
set -o errexit
|
||
|
set -o nounset
|
||
|
# set -o xtrace
|
||
|
|
||
|
# Set magic variables for current FILE & DIR
|
||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
|
||
|
__base="$(basename ${__file} .sh)"
|
||
|
__root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)"
|
||
|
|
||
|
# Set __usage and source main.sh
|
||
|
read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
|
||
|
-0 --zero Do nothing.
|
||
|
-1 --one Do one thing. Required.
|
||
|
More description.
|
||
|
-2 --two Do two things.
|
||
|
More. Required. Description.
|
||
|
-3 --three [arg] Do three things.
|
||
|
Required.
|
||
|
-4 --four {arg} Do four things.
|
||
|
-5 --five {arg} Do five things. Required. Maybe.
|
||
|
-6 --six [arg] Do six things. Not Required.
|
||
|
Required, it is not.
|
||
|
-7 --seven [arg] Required. Or bust.
|
||
|
-8 --eight [arg] Do eight things.
|
||
|
More.Required.Description.
|
||
|
-a [arg] Do A. Required.
|
||
|
Default="do-a"
|
||
|
-b {arg} Do B.Default="do-b"
|
||
|
-c [arg] Required. Default="do-c"
|
||
|
-d {arg} Default="do-d"
|
||
|
EOF
|
||
|
|
||
|
export __usage
|
||
|
export NO_COLOR="true"
|
||
|
|
||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||
|
|
||
|
echo "# complain about -3"
|
||
|
(source "${__root}/main.sh") || true
|
||
|
|
||
|
echo "# complain about -4"
|
||
|
(source "${__root}/main.sh" -3 arg3) || true
|
||
|
|
||
|
echo "# complain about -5"
|
||
|
(source "${__root}/main.sh" -3 arg3 -4 arg4) || true
|
||
|
|
||
|
echo "# complain about -8 (because -7 syntax is not supported)"
|
||
|
(source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5) || true
|
||
|
|
||
|
echo "# complain about -d (because -d syntax is not supported)"
|
||
|
(source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5 -8 arg8) || true
|
||
|
|
||
|
echo "# complain about nothing"
|
||
|
(
|
||
|
source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5 -8 arg8 -d argd
|
||
|
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
|
||
|
)
|