aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cpt-lib.in29
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() {