diff options
author | Kate Ward <kate.ward@forestent.com> | 2018-01-25 15:16:05 +0100 |
---|---|---|
committer | Kate Ward <kate.ward@forestent.com> | 2018-01-25 15:16:05 +0100 |
commit | c5f50be79a642a910dae5bed78bfdc30724e285c (patch) | |
tree | 498856217bb5cf12967d620b6a50a0b145bf5804 /examples | |
parent | 51ccc276e36e2554b593fc4c37ecf098bf96cc50 (diff) | |
download | shflags-c5f50be79a642a910dae5bed78bfdc30724e285c.tar.gz |
Fixed to work again after code reorg.
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/debug_output.sh | 16 | ||||
-rwxr-xr-x | examples/hello_world.sh | 8 |
2 files changed, 10 insertions, 14 deletions
diff --git a/examples/debug_output.sh b/examples/debug_output.sh index b3ecec2..a5e61c8 100755 --- a/examples/debug_output.sh +++ b/examples/debug_output.sh @@ -11,10 +11,10 @@ # $ ./debug_output.sh sing # $ ./debug_output.sh --debug sing -# source shflags -. ../src/shflags +# Source shflags. +. ../shflags -# define flags +# Define flags. DEFINE_boolean 'debug' false 'enable debug mode' 'd' FLAGS_HELP=`cat <<EOF commands: @@ -22,21 +22,17 @@ commands: sing: sing something EOF` - -debug() -{ +debug() { [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ] || return echo "DEBUG: $@" >&2 } -die() { - [ $# -gt 0 ] && echo "error: $@" >&2 +die() { [ $# -gt 0 ] && echo "error: $@" >&2 flags_help exit 1 } - -# parse the command-line +# Parse the command-line. FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" diff --git a/examples/hello_world.sh b/examples/hello_world.sh index 84b755a..e5fe81c 100755 --- a/examples/hello_world.sh +++ b/examples/hello_world.sh @@ -7,13 +7,13 @@ # '--name'). If a name is given, it is output, otherwise the default of 'world' # is output. -# source shflags -. ../src/shflags +# Source shflags. +. ../shflags -# define a 'name' command-line string flag +# Define a 'name' command-line string flag. DEFINE_string 'name' 'world' 'name to say hello to' 'n' -# parse the command-line +# Parse the command-line. FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" |