#!/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 binary files so they should be ignored contains "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 ;; --version|-v) version ;; *) util=$(SEARCH_PATH=$PATH pkg_find "cpt-$arg"* "" -x 2>/dev/null) || die "'cpt $arg' is not a valid command" "$util" "$@" ;; esac