diff options
author | merakor <cem@ckyln.com> | 2021-08-07 21:00:10 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-08-07 21:00:10 +0000 |
commit | 5edc00087343c9f1af7f345b86914c1f0fa94bfd (patch) | |
tree | fe86522d67fde64ff198cb81ff64dfe27ca6173f /src | |
parent | 79863f68c3016d9ab85d35b54e064621c1934041 (diff) | |
download | cpt-5edc00087343c9f1af7f345b86914c1f0fa94bfd.tar.gz |
global_options: add argument to call silent
FossilOrigin-Name: cab50844d5456d5bb7c10625e3f34038146b84780b93f3abed107c74378cc41f
Diffstat (limited to 'src')
-rw-r--r-- | src/cpt-lib.in | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in index c055331..0017fba 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -415,14 +415,29 @@ getoptions_help() { echo "}" } +# 2086: +# The lack of quotes are intentional. We do this so `getoptions()` do not try +# to parse the empty string. +# 2120: +# The library does not call this function with any positional arguments, but +# that does not mean that other programs will not do it, so this can also be +# safely ignored. +# shellcheck disable=2086,2120 global_options() { - msg -- '' 'Global Options:' - flag CPT_FORCE -f --force init:@export -- "Force operation" - flag CPT_PROMPT -y --no-prompt on:0 off:0 init:@export -- "Do not prompt for confirmation" - param CPT_ROOT --root init:@export -- "Use an alternate root directory" - disp :usage -h --help -- "Show this help message" - disp :version -v --version -- "Print version information" - flag CPT_VERBOSE --verbose init:@export -- "Be more verbose" + # These are options that are supported by most utilities. If the optional + # argument 'silent' is given, the usage will not print these options, but + # the arguments will still be accepted. Sometimes it doesn't make sense to + # pollute the screen with options that will be rarely ever used. + case $1 in + silent) h=hidden:1 ;; + *) msg -- '' 'Global Options:'; h='' + esac + flag CPT_FORCE -f --force $h init:@export -- "Force operation" + flag CPT_PROMPT -y --no-prompt on:0 off:0 $h init:@export -- "Do not prompt for confirmation" + param CPT_ROOT --root $h init:@export -- "Use an alternate root directory" + disp :usage -h --help $h -- "Show this help message" + disp :version -v --version $h -- "Print version information" + flag CPT_VERBOSE --verbose $h init:@export -- "Be more verbose" } contains() { |