From 9031dc631fa33a1493f5780943f8f888ce530178 Mon Sep 17 00:00:00 2001 From: merakor Date: Sat, 22 Aug 2020 15:03:10 +0000 Subject: cpt: remove getopt and use shell library instead. FossilOrigin-Name: cbe6d1050c67fcce58e754cd03832089ffeb33a5f9455c55e71738ab11e0d056 --- src/cpt-search | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/cpt-search') 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 -- cgit v1.2.3