aboutsummaryrefslogtreecommitdiff
path: root/src/cpt-search
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-08-22 15:03:10 +0000
committermerakor <cem@ckyln.com>2020-08-22 15:03:10 +0000
commit9031dc631fa33a1493f5780943f8f888ce530178 (patch)
tree8acd058d02ace545eb026e95a944e7bf9a0b4211 /src/cpt-search
parent01fb58cf040114841800d9cceba9d256278a4682 (diff)
downloadcpt-9031dc631fa33a1493f5780943f8f888ce530178.tar.gz
cpt: remove getopt and use shell library instead.
FossilOrigin-Name: cbe6d1050c67fcce58e754cd03832089ffeb33a5f9455c55e71738ab11e0d056
Diffstat (limited to 'src/cpt-search')
-rwxr-xr-xsrc/cpt-search29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/cpt-search b/src/cpt-search
index 7eaffb9..cc37d9a 100755
--- a/src/cpt-search
+++ b/src/cpt-search
@@ -4,23 +4,18 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-# By default we are showing all instances of a package. This value can be unset
-# in order to only find the first instance of a package.
-all=1
+parser_definition() {
+ setup REST -- "usage: ${0##*/} [pkg...]"
+ msg -- '' 'Options:'
+ flag all -s --single init:=1 on:'' -- "Only show the first instance of a package"
+ disp :usage -h --help -- "Show this help message"
+ disp :version -v --version -- "Print version information"
+}
-eval set -- "$(getopt -l single,version,help -- shv "$@")"
-while :; do
- case "$1" in
- --help|-h|'')
- out "usage: ${0##*/} [--single] [pkg...]" "" \
- " Options:" \
- " -s --single Only show the first instance of a package" ""
- exit 0
- ;;
- --version|-v) version ;;
- --single|-s) unset all; shift ;;
- --) shift; break ;;
- esac
-done
+eval "$(getoptions parser_definition parse "$0")"
+eval "$(getoptions_help parser_definition usage "$0")"
+
+parse "$@"
+eval set -- "$REST"
for pkg; do pkg_find "$pkg" "${all:+all}"; done