aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKate Ward <kate.ward@forestent.com>2018-01-25 15:16:05 +0100
committerKate Ward <kate.ward@forestent.com>2018-01-25 15:16:05 +0100
commitc5f50be79a642a910dae5bed78bfdc30724e285c (patch)
tree498856217bb5cf12967d620b6a50a0b145bf5804 /examples
parent51ccc276e36e2554b593fc4c37ecf098bf96cc50 (diff)
downloadshflags-c5f50be79a642a910dae5bed78bfdc30724e285c.tar.gz
Fixed to work again after code reorg.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/debug_output.sh16
-rwxr-xr-xexamples/hello_world.sh8
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}"