Allow for multiline opt description in __usage. Fixes #7

This commit is contained in:
Manuel Streuhofer
2016-11-11 01:13:28 +01:00
parent 0181129aff
commit 539443b3ca
4 changed files with 73 additions and 24 deletions

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,7 @@
ACCPTST:STDIO_REPLACE_DATETIMES
{datetime} UTC [ info] arg_1: 0
{datetime} UTC [ info] arg_2: 0
{datetime} UTC [ info] arg_3: THREE
{datetime} UTC [ info] arg_4: FOUR
{datetime} UTC [ info] arg_5: OOOPS
{datetime} UTC [ info] arg_6:

View 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