Refactor column output

- Use single function _columns_
- Use single variable for indentation
- add options for bold, underline, reverse for left column
This commit is contained in:
Nathaniel Landau
2022-04-28 23:30:10 -04:00
parent 8719caa6bd
commit b655220616
4 changed files with 99 additions and 134 deletions

View File

@@ -296,33 +296,18 @@ _usage_() {
This is a script template. Edit this description to print help to users.
${bold}${underline}Options:${reset}
$(_usageCommands_ \
"-h, --help" \
"Display this help and exit")
$(_usageCommands_ \
"--loglevel [LEVEL]" \
"One of: FATAL, ERROR (default), WARN, INFO, NOTICE, DEBUG, ALL, OFF")
$(_usageCommands_ \
"--logfile [FILE]" \
"Full PATH to logfile. (Default is '${HOME}/logs/$(basename "$0").log')")
$(_usageCommands_ \
"-n, --dryrun" \
"Non-destructive. Makes no permanent changes." \
2)
$(_usageCommands_ \
"-q, --quiet" \
"Quiet (no output)")
$(_usageCommands_ \
"-v, --verbose" \
"Output more information. (Items echoed to 'verbose')")
$(_usageCommands_ \
"--force" \
"Skip all user interaction. Implied 'Yes' to all actions.")
$(_columns_ -b -- '-h, --help' "Display this help and exit" 2)
$(_columns_ -b -- "--loglevel [LEVEL]" "One of: FATAL, ERROR (default), WARN, INFO, NOTICE, DEBUG, ALL, OFF" 2)
$(_columns_ -b -- "--logfile [FILE]" "Full PATH to logfile. (Default is '\${HOME}/logs/$(basename "$0").log')" 2)
$(_columns_ -b -- "-n, --dryrun" "Non-destructive. Makes no permanent changes." 2)
$(_columns_ -b -- "-q, --quiet" "Quiet (no output)" 2)
$(_columns_ -b -- "-v, --verbose" "Output more information. (Items echoed to 'verbose')" 2)
$(_columns_ -b -- "--force" "Skip all user interaction. Implied 'Yes' to all actions." 2)
${bold}${underline}Example Usage:${reset}
${gray}# Run the script and specify log level and log file.${reset}
$(basename "$0") -vn --logfile "/path/to/file.log" --loglevel 'WARN'
${gray}# Run the script and specify log level and log file.${reset}
$(basename "$0") -vn --logfile "/path/to/file.log" --loglevel 'WARN'
USAGE_TEXT
}