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