diff options
Diffstat (limited to 'examples/hello_world.sh')
-rwxr-xr-x | examples/hello_world.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/hello_world.sh b/examples/hello_world.sh new file mode 100755 index 0000000..6fb2cb0 --- /dev/null +++ b/examples/hello_world.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# This is the proverbial 'Hello, world!' script to demonstrate the most basic +# functionality of shFlags. +# +# This script demonstrates accepts a single command-line flag of '-n' (or +# '--name'). If a name is given, it is output, otherwise the default of 'world' +# is output. + +# source shflags +. ../src/shflags + +# define a 'name' command-line string flag +DEFINE_string 'name' 'world' 'name to say hello to' 'n' + +# parse the command-line +FLAGS "$@" || exit 1 +eval set -- "${FLAGS_ARGV}" + +echo "Hello, ${FLAGS_name}!" |