Add force -f option

This commit is contained in:
Rob Pearce 2021-09-05 08:06:52 +10:00
parent 238d77f7e3
commit 6d22982bbb
1 changed files with 9 additions and 2 deletions

11
t.sh
View File

@ -58,6 +58,7 @@ function usage() {
echo "usage: $0 COMMAND [OPTIONS] [commandopts]" echo "usage: $0 COMMAND [OPTIONS] [commandopts]"
echo echo
echo " -s Auto-sync with server when complete." echo " -s Auto-sync with server when complete."
echo " -f Assume 'yes' to all questions."
echo echo
printf "$format" "COMMAND" "DESCRIPTION" "SYNONYMS" printf "$format" "COMMAND" "DESCRIPTION" "SYNONYMS"
for x in $valid_modes; do for x in $valid_modes; do
@ -250,11 +251,15 @@ function error() {
} }
function info() { function info() {
[[ $AUTOYES -eq 1 ]] && return
echo -e "$BOLD${CYAN}>> $PLAIN$CYAN$*$PLAIN" echo -e "$BOLD${CYAN}>> $PLAIN$CYAN$*$PLAIN"
} }
function confirm() { function confirm() {
local yn local yn
if [[ $AUTOYES -eq 1 ]]; then
return 0
fi
echo -en "$BOLD${MAGENTA}CONFIRM: $PLAIN$MAGENTA$* (y/N)? $PLAIN" echo -en "$BOLD${MAGENTA}CONFIRM: $PLAIN$MAGENTA$* (y/N)? $PLAIN"
read yn read yn
if [[ $yn == "y" ]]; then if [[ $yn == "y" ]]; then
@ -1178,8 +1183,7 @@ DEBUG=0
TESTMODE=0 TESTMODE=0
AUTOSYNC=0 AUTOSYNC=0
ARGS="fhdsty"
ARGS="hdst"
while getopts "$ARGS" i; do while getopts "$ARGS" i; do
case "$i" in case "$i" in
h) h)
@ -1196,6 +1200,9 @@ while getopts "$ARGS" i; do
DEBUG=1 DEBUG=1
TESTMODE=1 TESTMODE=1
;; ;;
y|f)
AUTOYES=1
;;
*) *)
error "invalid argument: $i"; error "invalid argument: $i";
usage; usage;