mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2025-06-23 15:47:32 +00:00
Allow for multiline opt description in __usage. Fixes #7
This commit is contained in:
1
test/fixture/main-usage-defaults.exitcode
Normal file
1
test/fixture/main-usage-defaults.exitcode
Normal file
@ -0,0 +1 @@
|
||||
0
|
7
test/fixture/main-usage-defaults.stdio
Normal file
7
test/fixture/main-usage-defaults.stdio
Normal file
@ -0,0 +1,7 @@
|
||||
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||
{datetime} UTC [32m[ info][0m arg_1: 0
|
||||
{datetime} UTC [32m[ info][0m arg_2: 0
|
||||
{datetime} UTC [32m[ info][0m arg_3: THREE
|
||||
{datetime} UTC [32m[ info][0m arg_4: FOUR
|
||||
{datetime} UTC [32m[ info][0m arg_5: OOOPS
|
||||
{datetime} UTC [32m[ info][0m arg_6:
|
33
test/scenario/main-usage-defaults/run.sh
Executable file
33
test/scenario/main-usage-defaults/run.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/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
|
||||
-1 --one Do one thing. Default="ONE"
|
||||
More description.
|
||||
-2 --two Do two things.
|
||||
More description. Default="TWO"
|
||||
-3 --three [arg] Do three things. Default="THREE"
|
||||
More description.
|
||||
-4 --four [arg] Do four things.
|
||||
More description. Default="FOUR"
|
||||
-5 --five [arg] Do five things. Default="FIVE"
|
||||
More description. Default="OOOPS"
|
||||
-6 --six [arg] Do six things.
|
||||
More description.
|
||||
EOF
|
||||
|
||||
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||
|
||||
source "${__root}/main.sh"
|
||||
|
||||
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
|
Reference in New Issue
Block a user