Add --yes option
This commit is contained in:
@@ -36,6 +36,8 @@ printHelp() {
|
|||||||
Example: /dev/sdX
|
Example: /dev/sdX
|
||||||
--reset
|
--reset
|
||||||
Cleanup all source and output files
|
Cleanup all source and output files
|
||||||
|
--yes,-y
|
||||||
|
Assume yes for all questions (automatic mode)
|
||||||
--debug,-d
|
--debug,-d
|
||||||
--help,-h
|
--help,-h
|
||||||
|
|
||||||
@@ -143,13 +145,13 @@ init() {
|
|||||||
readInput() {
|
readInput() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
unset RESET
|
unset RESET YES
|
||||||
|
|
||||||
declare -ga PROFILES
|
declare -ga PROFILES
|
||||||
declare long_opts='release:,version:,profile:,buildroot:,source,'
|
declare long_opts='release:,version:,profile:,buildroot:,source,'
|
||||||
long_opts+='ssh-upgrade:,ssh-backup:,flash:,reset,debug,help'
|
long_opts+='ssh-upgrade:,ssh-backup:,flash:,reset,yes,debug,help'
|
||||||
|
|
||||||
if _input=$(getopt -o +r:v:p:b:sf:dh -l $long_opts -- "$@"); then
|
if _input=$(getopt -o +r:v:p:b:sf:ydh -l $long_opts -- "$@"); then
|
||||||
eval set -- "$_input"
|
eval set -- "$_input"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -177,6 +179,9 @@ readInput() {
|
|||||||
--reset)
|
--reset)
|
||||||
RESET=1
|
RESET=1
|
||||||
;;
|
;;
|
||||||
|
--yes|-y)
|
||||||
|
YES=1
|
||||||
|
;;
|
||||||
--debug|-d)
|
--debug|-d)
|
||||||
echo "Debugging on"
|
echo "Debugging on"
|
||||||
DEBUG=1
|
DEBUG=1
|
||||||
@@ -564,13 +569,10 @@ fromSource() {
|
|||||||
[0-9][0-9].[0-9][0-9].*)
|
[0-9][0-9].[0-9][0-9].*)
|
||||||
local branch="openwrt-${RELEASE%.*}"
|
local branch="openwrt-${RELEASE%.*}"
|
||||||
local tag="v$RELEASE"
|
local tag="v$RELEASE"
|
||||||
local r
|
if askOk "Use HEAD of $branch branch (y, recommended) or $tag tag (n)?"; then
|
||||||
read -r -p "Use HEAD of $branch branch (y, recommended) or $tag tag (n)? (Y/n): " r
|
|
||||||
r=${r,,}
|
|
||||||
if [[ "$r" =~ ^(no|n)$ ]]; then
|
|
||||||
execute "${wt_cmd[@]}" "$tag"
|
|
||||||
else
|
|
||||||
execute "${wt_cmd[@]}" "origin/$branch"
|
execute "${wt_cmd[@]}" "origin/$branch"
|
||||||
|
else
|
||||||
|
execute "${wt_cmd[@]}" "$tag"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -673,6 +675,7 @@ fromSource() {
|
|||||||
# Generic helpers
|
# Generic helpers
|
||||||
debug() { (( DEBUG )) && echo "Debug: $*"; }
|
debug() { (( DEBUG )) && echo "Debug: $*"; }
|
||||||
askOk() {
|
askOk() {
|
||||||
|
(( YES )) && return
|
||||||
local r
|
local r
|
||||||
read -r -p "$* [y/N]: " r
|
read -r -p "$* [y/N]: " r
|
||||||
r=${r,,}
|
r=${r,,}
|
||||||
|
|||||||
Reference in New Issue
Block a user