diff options
author | merakor <cem@ckyln.com> | 2020-10-05 11:05:46 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-10-05 11:05:46 +0000 |
commit | 39af6dbdc87390fa44600482fe6ed21d220e4a93 (patch) | |
tree | 749309bf4dc544999c061e233827ee85cbfa1631 /src | |
parent | 9b99b0e1eed60a63d93f7225b61f845d6759a8a7 (diff) | |
download | cpt-39af6dbdc87390fa44600482fe6ed21d220e4a93.tar.gz |
cpt: add global options to the library.
FossilOrigin-Name: 31d397b6064679068ed32c337f8c74e7ab24c9b7b9fa44f55a8cc0f52ca3bcee
Diffstat (limited to 'src')
-rwxr-xr-x | src/cpt-build | 4 | ||||
-rwxr-xr-x | src/cpt-install | 4 | ||||
-rw-r--r-- | src/cpt-lib | 8 | ||||
-rwxr-xr-x | src/cpt-remove | 4 | ||||
-rwxr-xr-x | src/cpt-search | 3 | ||||
-rwxr-xr-x | src/cpt-update | 5 |
6 files changed, 13 insertions, 15 deletions
diff --git a/src/cpt-build b/src/cpt-build index e872170..1b1e055 100755 --- 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 index 94058d8..082d9d1 100755 --- 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 index 8509776..27e8c4d 100644 --- 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 index 0d63ece..fc4cf43 100755 --- 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 index 5fb851d..d52f5c9 100755 --- 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 index 8bc29f2..4b2e7bd 100755 --- 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")" |