aboutsummaryrefslogtreecommitdiff
path: root/contrib/cpt-cat
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cpt-cat')
-rwxr-xr-xcontrib/cpt-cat32
1 files changed, 19 insertions, 13 deletions
diff --git a/contrib/cpt-cat b/contrib/cpt-cat
index bfc9d66..45e0dd9 100755
--- a/contrib/cpt-cat
+++ b/contrib/cpt-cat
@@ -28,23 +28,29 @@
## .Em version
## files.
-case "$1" in
- --help|-h)
- printf 'usage: %s [pkg] [file...]\n' "${0##*/}"
- exit 0
- ;;
- '')
- [ "$#" -gt 1 ] && shift
- set -- "${PWD##*/}" "$@"
-esac
+parser_definition() {
+ setup REST help:usage -- "usage: ${0##*/} [pkg] [file...]"
+ global_options silent
+}
+
+# shellcheck disable=1091
+. cpt-lib
+
+[ "$1" ] || {
+ # Usage such as `cpt-cat '' build` is also valid.
+ [ "$#" -gt 1 ] && shift
+ set -- "${PWD##*/}" "$@"
+}
pkg=$1; shift
-cpt-list "$pkg" >/dev/null
+pkg_list "$pkg" >/dev/null
[ "$1" ] || set -- build depends sources version
+# $sys_db and color variables are defined by cpt-lib
+# shellcheck disable=2154
for file; do
- [ -f "$CPT_ROOT/var/db/cpt/installed/$pkg/$file" ] || continue
- printf '\033[1m%s:\033[m\n' "$file" >&2
- cat "$CPT_ROOT/var/db/cpt/installed/$pkg/$file"
+ [ -f "$sys_db/$pkg/$file" ] || continue
+ printf '%b%s:%b\n' "$colbold" "$file" "$colre" >&2
+ cat "$sys_db/$pkg/$file"
done