File tree Expand file tree Collapse file tree 1 file changed +30
-7
lines changed Expand file tree Collapse file tree 1 file changed +30
-7
lines changed Original file line number Diff line number Diff line change 22
33set -euo pipefail
44
5+ function printHelpText
6+ {
7+ echo " Usage:"
8+ echo " ${0} [OPTIONS]"
9+ echo " "
10+ echo " application Options:"
11+ echo " -p, --default-clone-path= Default path to git clone into (default: ./)"
12+ echo " -f, --gitfile= File path to the Gitfile (default: ./gitfile)"
13+ echo " "
14+ echo " Help Options:"
15+ echo " -h, --help Show this help message and exit"
16+ echo " "
17+ exit 0
18+ }
19+
520function cloneRepo
621{
722 SOURCE=${1}
@@ -46,15 +61,23 @@ function parseYaml
4661}
4762
4863DEFAULT_GIT_CLONE_PATH=" ."
49- if [ " $# " -eq 1 ]; then
50- DEFAULT_GIT_CLONE_PATH=${1%/ }
51- fi
64+ YAML_FILE=" ./.gitfile"
65+ while [ " $# " -gt 0 ]; do
66+ case " $1 " in
67+ -p) DEFAULT_GIT_CLONE_PATH=" ${2%/ } " ; shift 2;;
68+ -f) YAML_FILE=" $2 " ; shift 2;;
5269
70+ --default-clone-path=* ) DEFAULT_GIT_CLONE_PATH=" ${1#* =} " ; shift 1;;
71+ --gitfile=* ) YAML_FILE=" ${1#* =} " ; shift 1;;
72+ --default-clone-path|--gitfile) echo " $1 requires an argument" >&2 ; exit 1;;
5373
54- YAML_FILE=" ./.gitfile"
55- if [ " $# " -eq 2 ]; then
56- YAML_FILE=" ${2} "
57- fi
74+ -h) printHelpText;;
75+ --help) printHelpText;;
76+
77+ -* ) echo " unknown option: $1 " >&2 ; exit 1;;
78+ * ) handle_argument " $1 " ; shift 1;;
79+ esac
80+ done
5881
5982if [ ! -f " ${YAML_FILE} " ]; then
6083 echo " [ERROR] '${YAML_FILE} ' does not exist"
You can’t perform that action at this time.
0 commit comments