#!/bin/sh -ef # shellcheck disable=1091 if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi # If none of the tools below are specified, we will reenable glob unset glob [ "$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|alternatives) arg=alternatives ;; b|build) arg=build ;; c|checksum) arg=checksum ;; d|download) arg=download ;; f|fetch) arg=fetch ;; i|install) arg=install ;; l|list) arg=list ;; r|remove) arg=remove ;; s|search) arg=search ;; u|update) arg=update ;; *) glob=1 ;; esac util=$(SEARCH_PATH=$PATH pkg_find "cpt-$arg${glob:+*}" "" -x 2>/dev/null) || die "'cpt $arg' is not a valid command" "$util" "$@"