aboutsummaryrefslogtreecommitdiff
path: root/src/cpt-search
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-08-20 11:47:16 +0000
committermerakor <cem@ckyln.com>2020-08-20 11:47:16 +0000
commit9cdb80efe673152f90adba24fb2248532c2a637e (patch)
tree8017eb73bb9665b15a84a321f8a1557f48dfe5e2 /src/cpt-search
parent86b14ef1524c3b700ba1990285a5535c835a7ba0 (diff)
downloadcpt-9cdb80efe673152f90adba24fb2248532c2a637e.tar.gz
cpt: use 'getopt' for option parsing
FossilOrigin-Name: 65f22dd80a83335174c541e38f6b4c2c870e813faa587d06ed8989b50018fc09
Diffstat (limited to 'src/cpt-search')
-rwxr-xr-xsrc/cpt-search24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/cpt-search b/src/cpt-search
index 47faaf7..7eaffb9 100755
--- a/src/cpt-search
+++ b/src/cpt-search
@@ -8,15 +8,19 @@ if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
# in order to only find the first instance of a package.
all=1
-case "$1" in
- --help|-h|'')
- out "usage: ${0##*/} [--single] [pkg...]" "" \
- " Options:" \
- " --single Only show the first instance of a package" ""
- exit 0
- ;;
- --version|-v) version ;;
- --single) unset all; shift ;;
-esac
+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
for pkg; do pkg_find "$pkg" "${all:+all}"; done