diff options
author | merakor <cem@ckyln.com> | 2020-07-24 14:04:47 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-07-24 14:04:47 +0000 |
commit | be96172e98b7289b032e1a87f13259c560920996 (patch) | |
tree | ad48e938c46db20cc177c2b8a82943824719fba2 /tools/cpt | |
parent | b2b8c0ae3774cb9a854799d2aa0f77fa4101aa07 (diff) | |
download | cpt-be96172e98b7289b032e1a87f13259c560920996.tar.gz |
cpt: keep the file structure simpler
FossilOrigin-Name: b548c2cdb7abfada1c7527565e5a58b2de5bbb6d620682454828cee7ae15b5db
Diffstat (limited to 'tools/cpt')
-rwxr-xr-x | tools/cpt | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/cpt b/tools/cpt new file mode 100755 index 0000000..9585330 --- /dev/null +++ b/tools/cpt @@ -0,0 +1,44 @@ +#!/bin/sh -ef +# shellcheck disable=1091 + +if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./lib.sh; fi + +[ "$1" ] && { arg=$1; shift; } +case "$arg" in + --help|-h|'') + log "Carbs Packaging Tool" + set -- + for path in $(SEARCH_PATH=$PATH pkg_find cpt-* all -x); do + set -- "${path#*/cpt-}" "$@" + max=$((${#1} > max ? ${#1} : max)) + done + + for path; do + # These are the files to be ignored. + contains "lib readlink stat" "$path" && continue + + 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) 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=$(SEARCH_PATH=$PATH pkg_find "cpt-$arg"* "" -x 2>/dev/null) || + die "'cpt $arg' is not a valid command" + +"$util" "$@" |