aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-08-10 22:18:09 +0000
committermerakor <cem@ckyln.com>2021-08-10 22:18:09 +0000
commitfcc7cdd594dd8b8aed6997449d326183d4a162bc (patch)
treecbb10930bf3d08ede1f34dbe25f0d59725e72bd0
parentbe382307d3c47fb02b30836be3cea4220058f01a (diff)
downloadcpt-fcc7cdd594dd8b8aed6997449d326183d4a162bc.tar.gz
cpt-cat: use cpt-lib
FossilOrigin-Name: 15f01aa2858b7585dbaaef0f7d749def286ce57fa5d2e2f838c0a153c175859d
-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