Skip to content

Commit

Permalink
MOD: .gitignore bashew.sh script.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
pforret committed Dec 1, 2023
1 parent bea6c2f commit ca55536
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ log/
.tmp
.bashew*
log
/temp/
28 changes: 4 additions & 24 deletions bashew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -578,42 +578,24 @@ check_script_settings() {
IO:print "## ${col_grn}boolean flags${col_reset}:"
filter_option_type flag |
while read -r name; do
if ((piped)); then
eval "echo \"$name=\$${name:-}\""
else
eval "echo -n \"$name=\$${name:-} \""
fi
declare -p "$name" | cut -d' ' -f3-
done
IO:print " "
IO:print " "
fi

if [[ -n $(filter_option_type option) ]]; then
IO:print "## ${col_grn}option defaults${col_reset}:"
filter_option_type option |
while read -r name; do
if ((piped)); then
eval "echo \"$name=\$${name:-}\""
else
eval "echo -n \"$name=\$${name:-} \""
fi
declare -p "$name" | cut -d' ' -f3-
done
IO:print " "
IO:print " "
fi

if [[ -n $(filter_option_type list) ]]; then
IO:print "## ${col_grn}list options${col_reset}:"
filter_option_type list |
while read -r name; do
if ((piped)); then
eval "echo \"$name=(\${${name}[@]})\""
else
eval "echo -n \"$name=(\${${name}[@]}) \""
fi
declare -p "$name" | cut -d' ' -f3-
done
IO:print " "
IO:print " "
fi

if [[ -n $(filter_option_type param) ]]; then
Expand All @@ -623,10 +605,8 @@ check_script_settings() {
IO:print "## ${col_grn}parameters${col_reset}:"
filter_option_type param |
while read -r name; do
# shellcheck disable=SC2015
((piped)) && eval "echo \"$name=\\\"\${$name:-}\\\"\"" || eval "echo -n \"$name=\\\"\${$name:-}\\\" \""
declare -p "$name" | cut -d' ' -f3-
done
echo " "
fi
fi
}
Expand Down
35 changes: 7 additions & 28 deletions template/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
### ==============================================================================
### SO HOW DO YOU PROCEED WITH YOUR SCRIPT?
### 1. define the flags/options/parameters and defaults you need in Option:config()
### 2. implement the different actions in Script:main() with helper functions
### 2. implement the different actions in Script:main() directly or with helper functions do_action1
### 3. implement helper functions you defined in previous step
### ==============================================================================

Expand Down Expand Up @@ -52,7 +52,7 @@ flag|f|force|do not ask for confirmation (always yes)
option|l|log_dir|folder for log files |$HOME/log/$script_prefix
option|t|tmp_dir|folder for temp files|/tmp/$script_prefix
choice|1|action|action to perform|action1,action2,check,env,update
#param|?|input|input file/text
param|?|input|input file/text
" -v -e '^#' -e '^\s*$'
}

Expand Down Expand Up @@ -498,39 +498,24 @@ Script:check() {
IO:print "## ${txtInfo}boolean flags${txtReset}:"
Option:filter flag |
while read -r name; do
if ((piped)); then
eval "echo \"$name=\$${name:-}\""
else
eval "echo -n \"$name=\$${name:-} \""
fi
declare -p "$name" | cut -d' ' -f3-
done
IO:print " "
fi

if [[ -n $(Option:filter option) ]]; then
IO:print "## ${txtInfo}option defaults${txtReset}:"
Option:filter option |
while read -r name; do
if ((piped)); then
eval "echo \"$name=\$${name:-}\""
else
eval "echo -n \"$name=\$${name:-} \""
fi
declare -p "$name" | cut -d' ' -f3-
done
IO:print " "
fi

if [[ -n $(Option:filter list) ]]; then
IO:print "## ${txtInfo}list options${txtReset}:"
Option:filter list |
while read -r name; do
if ((piped)); then
eval "echo \"$name=(\${${name}[@]})\""
else
eval "echo -n \"$name=(\${${name}[@]}) \""
fi
declare -p "$name" | cut -d' ' -f3-
done
IO:print " "
fi

if [[ -n $(Option:filter param) ]]; then
Expand All @@ -540,12 +525,9 @@ Script:check() {
IO:print "## ${txtInfo}parameters${txtReset}:"
Option:filter param |
while read -r name; do
# shellcheck disable=SC2015
((piped)) && eval "echo \"$name=\\\"\${$name:-}\\\"\"" || eval "echo -n \"$name=\\\"\${$name:-}\\\" \""
declare -p "$name" | cut -d' ' -f3-
done
echo " "
fi
IO:print " "
fi

if [[ -n $(Option:filter choice) ]]; then
Expand All @@ -555,12 +537,9 @@ Script:check() {
IO:print "## ${txtInfo}choice${txtReset}:"
Option:filter choice |
while read -r name; do
# shellcheck disable=SC2015
((piped)) && eval "echo \"$name=\\\"\${$name:-}\\\"\"" || eval "echo -n \"$name=\\\"\${$name:-}\\\" \""
declare -p "$name" | cut -d' ' -f3-
done
echo " "
fi
IO:print " "
fi

IO:print "## ${txtInfo}required commands${txtReset}:"
Expand Down

0 comments on commit ca55536

Please sign in to comment.