3 ms·
I feel like I'm spamming these comments with this, but check out https://bash3boilerplate.sh/ https://bash3boilerplate.sh/ for a much better logging system alon
by ndsipa_pomu 4y ago
I feel like I'm spamming these comments with this, but check out https://bash3boilerplate.sh/ https://bash3boilerplate.sh/ for a much better logging system along with a neat way of parsing options. You define the usage and help section like so to define your options:
### Usage and help - change this for each script
##############################################################################
# shellcheck disable=SC2015
[[ "${__usage+x}" ]] || read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
-t --timestamps Enable timestamps in output
-v --verbose Enable verbose mode, print script as it is executed
-d --debug Enables debug mode
-h --help This page
-n --no-color Disable color output
EOF
Then you get to refer to ${arg_t} for the --timestamps option etc.