Last active
February 7, 2017 19:57
-
-
Save grampelberg/5230815 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
usage() { | |
cat << EOF | |
usage: $0 [options] <argv>... | |
Options: | |
-h Show help options. | |
-v Print version info. | |
EOF | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
help=$(grep "^## " "${BASH_SOURCE[0]}" | cut -c 4-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#- usage-example 1.0 | |
#- Copyright (C) 2013 Thomas Rampelberg | |
## Usage: usage-example [options] <argv>... | |
## | |
## -h Show help options. | |
## -v Print version info. | |
help=$(grep "^## " "${BASH_SOURCE[0]}" | cut -c 4-) | |
version=$(grep "^#- " "${BASH_SOURCE[0]}" | cut -c 4-) | |
opt_h() { | |
echo "$help" | |
} | |
opt_v() { | |
echo "$version" | |
} | |
while getopts "hv" opt; do | |
eval "opt_$opt" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment