commit f9689e313cc6c3f277d8f94e481b171c115827fd parent 6c55165fd197d584aacc17e65cfc6568c17f5e46 Author: Cem Keylan <cem@ckyln.com> Date: Fri, 24 Jul 2020 14:19:09 +0300 cpt: reserve arguments Diffstat:
M | cpt | | | 26 | ++++++++++++++++++-------- |
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/cpt b/cpt @@ -20,15 +20,25 @@ case "$arg" in printf "%b->%b %-${max}s " "${color:+\033[1;31m}" "${color:+\033[m}" "${path#*/cpt-}" sed -n 's/^# *//;2p' "$(command -v "cpt-$path")" done | sort -uk1 >&2 + exit ;; - --version|-v) version ;; - - *) - util=$(SEARCH_PATH=$PATH pkg_find "cpt-$arg"* "" -x 2>/dev/null) || - die "'cpt $arg' is not a valid command" + --version|-v|version) version ;; + + # Reserve these arguments for the following tools. + a) arg=alternatives ;; + b) arg=build ;; + c) arg=checksum ;; + d) arg=download ;; + f) arg=fetch ;; + i) arg=install ;; + l) arg=list ;; + r) arg=remove ;; + s) arg=search ;; + u) arg=update ;; +esac - "$util" "$@" - ;; +util=$(SEARCH_PATH=$PATH pkg_find "cpt-$arg"* "" -x 2>/dev/null) || + die "'cpt $arg' is not a valid command" -esac +"$util" "$@"