kate.ward | 90fd99d | 2008-06-18 20:51:29 +0000 | [diff] [blame] | 1 | #!/bin/sh |
kate.ward | 120b504 | 2008-06-27 08:58:03 +0000 | [diff] [blame] | 2 | # |
kate.ward | 120b504 | 2008-06-27 08:58:03 +0000 | [diff] [blame] | 3 | # This is the proverbial 'Hello, world!' script to demonstrate the most basic |
| 4 | # functionality of shFlags. |
| 5 | # |
| 6 | # This script demonstrates accepts a single command-line flag of '-n' (or |
| 7 | # '--name'). If a name is given, it is output, otherwise the default of 'world' |
| 8 | # is output. |
kate.ward | 90fd99d | 2008-06-18 20:51:29 +0000 | [diff] [blame] | 9 | |
| 10 | # source shflags |
| 11 | . ../src/shflags |
| 12 | |
| 13 | # define a 'name' command-line string flag |
| 14 | DEFINE_string 'name' 'world' 'name to say hello to' 'n' |
| 15 | |
| 16 | # parse the command-line |
kate.ward | c521068 | 2009-03-30 18:54:36 +0000 | [diff] [blame] | 17 | FLAGS "$@" || exit 1 |
| 18 | eval set -- "${FLAGS_ARGV}" |
kate.ward | 90fd99d | 2008-06-18 20:51:29 +0000 | [diff] [blame] | 19 | |
| 20 | echo "Hello, ${FLAGS_name}!" |