diff options
author | merakor <cem@ckyln.com> | 2020-08-20 11:47:16 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-08-20 11:47:16 +0000 |
commit | 9cdb80efe673152f90adba24fb2248532c2a637e (patch) | |
tree | 8017eb73bb9665b15a84a321f8a1557f48dfe5e2 /src/cpt-build | |
parent | 86b14ef1524c3b700ba1990285a5535c835a7ba0 (diff) | |
download | cpt-9cdb80efe673152f90adba24fb2248532c2a637e.tar.gz |
cpt: use 'getopt' for option parsing
FossilOrigin-Name: 65f22dd80a83335174c541e38f6b4c2c870e813faa587d06ed8989b50018fc09
Diffstat (limited to 'src/cpt-build')
-rwxr-xr-x | src/cpt-build | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/cpt-build b/src/cpt-build index a143b67..0a4326b 100755 --- a/src/cpt-build +++ b/src/cpt-build @@ -4,11 +4,21 @@ # shellcheck disable=1091 if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi -case "$1" in - '') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH ;; - --help|-h) out "usage: ${0##*/} [pkg...]"; exit 1 ;; - --version|-v) version ;; -esac +eval set -- "$(getopt -l no-prompt,version,help -- yvh "$@")" +while :; do + case "$1" in + --help|-h) + out "usage: ${0##*/} [pkg...]" "" \ + " Options:" \ + " -y --no-prompt Do not prompt for confirmation" \ + exit 1 ;; + --version|-v) version ;; + --no-prompt|-y) export CPT_PROMPT=0; shift ;; + --) shift; break ;; + esac +done + +[ "$1" ] || set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH create_cache |