Use --non-interactive instead of --yes and use getopt for parsing short opts

This commit is contained in:
Brad Warren
2016-05-09 19:08:25 -07:00
parent 7f8fadee37
commit f38d59d675
2 changed files with 36 additions and 26 deletions
+18 -13
View File
@@ -29,15 +29,26 @@ all arguments you have provided.
Help for certbot itself cannot be provided until it is installed. Help for certbot itself cannot be provided until it is installed.
--debug attempt installation on experimental platforms --debug attempt experimental installation
--help print this help -h, --help print this help
--no-self-upgrade do not download updates for certbot or certbot-auto -n, --non-interactive, --noninteractive run without asking for user input
--os-packages-only install OS dependencies and exit --no-self-upgrade do not download updates
-v, --verbose provide more output --os-packages-only install OS dependencies and exit
--yes assume yes is the answer to all prompts -v, --verbose provide more output
All arguments are accepted and forwarded to the Certbot client when run." All arguments are accepted and forwarded to the Certbot client when run."
while getopts ":hnv" arg; do
case $arg in
h)
HELP=1;;
n)
ASSUME_YES=1;;
v)
VERBOSE=1;;
esac
done
for arg in "$@" ; do for arg in "$@" ; do
case "$arg" in case "$arg" in
--debug) --debug)
@@ -50,16 +61,10 @@ for arg in "$@" ; do
NO_SELF_UPGRADE=1;; NO_SELF_UPGRADE=1;;
--help) --help)
HELP=1;; HELP=1;;
--yes) --noninteractive|--non-interactive)
ASSUME_YES=1;; ASSUME_YES=1;;
--verbose) --verbose)
VERBOSE=1;; VERBOSE=1;;
[!-]*|-*[!v]*|-)
# Anything that isn't -v, -vv, etc.: that is, anything that does not
# start with a -, contains anything that's not a v, or is just "-"
;;
*) # -v+ remains.
VERBOSE=1;;
esac esac
done done
@@ -29,15 +29,26 @@ all arguments you have provided.
Help for certbot itself cannot be provided until it is installed. Help for certbot itself cannot be provided until it is installed.
--debug attempt installation on experimental platforms --debug attempt experimental installation
--help print this help -h, --help print this help
--no-self-upgrade do not download updates for certbot or certbot-auto -n, --non-interactive, --noninteractive run without asking for user input
--os-packages-only install OS dependencies and exit --no-self-upgrade do not download updates
-v, --verbose provide more output --os-packages-only install OS dependencies and exit
--yes assume yes is the answer to all prompts -v, --verbose provide more output
All arguments are accepted and forwarded to the Certbot client when run." All arguments are accepted and forwarded to the Certbot client when run."
while getopts ":hnv" arg; do
case $arg in
h)
HELP=1;;
n)
ASSUME_YES=1;;
v)
VERBOSE=1;;
esac
done
for arg in "$@" ; do for arg in "$@" ; do
case "$arg" in case "$arg" in
--debug) --debug)
@@ -50,16 +61,10 @@ for arg in "$@" ; do
NO_SELF_UPGRADE=1;; NO_SELF_UPGRADE=1;;
--help) --help)
HELP=1;; HELP=1;;
--yes) --noninteractive|--non-interactive)
ASSUME_YES=1;; ASSUME_YES=1;;
--verbose) --verbose)
VERBOSE=1;; VERBOSE=1;;
[!-]*|-*[!v]*|-)
# Anything that isn't -v, -vv, etc.: that is, anything that does not
# start with a -, contains anything that's not a v, or is just "-"
;;
*) # -v+ remains.
VERBOSE=1;;
esac esac
done done