From 9cdb80efe673152f90adba24fb2248532c2a637e Mon Sep 17 00:00:00 2001 From: merakor Date: Thu, 20 Aug 2020 11:47:16 +0000 Subject: cpt: use 'getopt' for option parsing FossilOrigin-Name: 65f22dd80a83335174c541e38f6b4c2c870e813faa587d06ed8989b50018fc09 --- src/cpt-build | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/cpt-build') 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 -- cgit v1.2.3