cpt

Carbs Packaging Tools
git clone git://git.carbslinux.org/cpt
Log | Files | Refs | README | LICENSE

commit 66ac98bcaa937f8ace171590510313e7ff883560
parent e92e638bc2288cd0daae961deca8e1ffe8bb99af
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon,  5 Oct 2020 14:05:47 +0300

cpt: add global options to the library.

Diffstat:
Msrc/cpt-build | 4+---
Msrc/cpt-install | 4+---
Msrc/cpt-lib | 8++++++++
Msrc/cpt-remove | 4+---
Msrc/cpt-search | 3+--
Msrc/cpt-update | 5+----
6 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/cpt-build b/src/cpt-build @@ -6,10 +6,8 @@ if [ -f ./cpt-lib ]; then . ./cpt-lib; else . cpt-lib; fi parser_definition() { setup REST -- "usage: ${0##*/} [pkg...]" msg -- '' 'Options:' - flag CPT_PROMPT -y --no-prompt on:0 off:0 init:="$CPT_PROMPT" -- "Do not prompt for confirmation" flag CPT_TEST -t --test init:="$CPT_TEST" -- "Run tests (if it exists)" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" + global_options } eval "$(getoptions parser_definition parse "$0")" diff --git a/src/cpt-install b/src/cpt-install @@ -7,9 +7,7 @@ parser_definition() { setup REST -- "usage: ${0##*/} [pkg...]" msg -- '' 'Options:' flag CPT_FORCE -f --force init:="$CPT_FORCE" -- "Force installation" - param CPT_ROOT --root init:="$CPT_ROOT" -- "Use an alternate root directory" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" + global_options } eval "$(getoptions parser_definition parse "$0")" diff --git a/src/cpt-lib b/src/cpt-lib @@ -276,6 +276,14 @@ getoptions_help() { echo "}" } +global_options() { + msg -- '' 'Global Options:' + flag CPT_FORCE -f --force init:="$CPT_FORCE" -- "Force operation" + flag CPT_PROMPT -y --no-prompt on:0 off:0 init:="$CPT_PROMPT" -- "Do not prompt for confirmation" + param CPT_ROOT --root init:="$CPT_ROOT" -- "Use an alternate root directory" + disp :usage -h --help -- "Show this help message" + disp :version -v --version -- "Print version information" +} warn() { # Print a warning message diff --git a/src/cpt-remove b/src/cpt-remove @@ -7,9 +7,7 @@ parser_definition() { setup REST -- "usage: ${0##*/} [pkg...]" msg -- '' 'Options:' flag CPT_FORCE -f --force init:="$CPT_FORCE" -- "Force removal" - param CPT_ROOT --root init:="$CPT_ROOT" -- "Use an alternate root directory" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" + global_options } eval "$(getoptions parser_definition parse "$0")" diff --git a/src/cpt-search b/src/cpt-search @@ -7,8 +7,7 @@ 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" + global_flags } eval "$(getoptions parser_definition parse "$0")" diff --git a/src/cpt-update b/src/cpt-update @@ -8,10 +8,7 @@ parser_definition() { msg -- '' 'Options:' flag download_only -d --download -- "Only download updatable packages" flag CPT_FETCH -n --no-fetch on:0 off:0 init:="$CPT_FETCH" -- "Do not refresh the repositories" - flag CPT_PROMPT -y --no-prompt on:0 off:0 init:="$CPT_PROMPT" -- "Do not prompt for confirmation" - param CPT_ROOT --root init:="$CPT_ROOT" -- "Use an alternate root directory" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" + global_options } eval "$(getoptions parser_definition parse "$0")"