aboutsummaryrefslogtreecommitdiff
path: root/contrib/cpt-cat
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cpt-cat')
-rwxr-xr-xcontrib/cpt-cat30
1 files changed, 18 insertions, 12 deletions
diff --git a/contrib/cpt-cat b/contrib/cpt-cat
index bfc9d66..652ee7c 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
for file; do
- [ -f "$CPT_ROOT/var/db/cpt/installed/$pkg/$file" ] || continue
+ # $sys_db is defined by cpt-lib
+ # shellcheck disable=2154
+ [ -f "$sys_db/$pkg/$file" ] || continue
printf '\033[1m%s:\033[m\n' "$file" >&2
- cat "$CPT_ROOT/var/db/cpt/installed/$pkg/$file"
+ cat "$sys_db/$pkg/$file"
done