File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33set -e
44
5- # # Get the options and store them in variables
6- while getopts " d::a::w::" opt; do
7- declare " option_$opt =${OPTARG:- 0} "
5+ # # Parse command line
6+ function usage() {
7+ cat << EOS
8+ Usage:
9+ git standup [-a <author name>] [-w <weekstart-weekend>] [-d <days-ago>] [-h]
10+
11+ -a - Specify author to restrict search to
12+ -w - Specify weekday range to limit search to
13+ -h - Display this help screen
14+
15+ Examples:
16+ git standup -a "John Doe" -w "MON-FRI"
17+ EOS
18+ }
19+
20+ while getopts " hd:a:w:" opt; do
21+ case $opt in
22+ h|d|a|w)
23+ declare " option_$opt =${OPTARG:- 0} "
24+ ;;
25+ \? )
26+ echo >&2 " Use 'git standup -h' to see usage info"
27+ exit 1
28+ ;;
29+ esac
830done
9-
10- # # If some options were given but none of them were the ones that we allow
11- if [[ ! $option_a ]] && [[ ! $option_d ]] && [[ ! $option_w ]] && [[ $# -gt 0 ]] ; then
12- >&2 echo -e " Usage: $0 [-a <author name>] [-w <weekstart-weekend>] [-d <days-ago>]\nExample: $0 -a \" John Doe \" -w \" MON-FRI \" "
31+ shift $(( OPTIND - 1 ))
32+ if [[ $# -gt 0 ]] ; then
33+ echo >&2 " Invalid arguments: $@ "
34+ echo >&2 " Use 'git standup -h' to see usage info "
1335 exit 1
1436fi
1537
38+ # Main script
39+
40+ if [[ $option_h ]]; then
41+ usage
42+ exit 0
43+ fi
44+
1645# Use colors, but only if connected to a terminal, and that terminal
1746# supports them.
1847if [[ -t 1 ]] && [[ -n " $TERM " ]] && which tput & > /dev/null && tput colors & > /dev/null; then
You can’t perform that action at this time.
0 commit comments