diff options
author | merakor <cem@ckyln.com> | 2020-07-24 14:11:03 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-07-24 14:11:03 +0000 |
commit | 3bbb028b00fafc5c0d5e47c96e21a61ef5e842ac (patch) | |
tree | bef990822c87175e2eb074ae3961863a5b175c98 /src/cpt | |
parent | 0d634aa1f1710d949a5498cd3803a17c5426ca6a (diff) | |
download | cpt-3bbb028b00fafc5c0d5e47c96e21a61ef5e842ac.tar.gz |
tools: move to src
FossilOrigin-Name: e320e235b6dd6b0d4b0d04df12c1c5e481c524412d286dc6375b6cd4231eed8b
Diffstat (limited to 'src/cpt')
-rwxr-xr-x | src/cpt | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -0,0 +1,44 @@ +#!/bin/sh -ef +# shellcheck disable=1091 + +if command -v cpt-lib >/dev/null; then . cpt-lib; else ./cpt-lib; 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" "$@" |