This should later probably be split so we have dedicated varnames for the different types, as we're now making the template uglier just to accomodate our tests
* Add support for declaring arguments as repeatable
If the usage of the argument includes the phrase "Can be repeated.",
the corresponding arg_ variable will be an array containing one element
per instance of the argument.
* Add example and test for using repeated parameters
* Add example and test for using repeated flags
SC2235: The warning/suggestion about the subshell was letigimate, so
the suggested fix is implemented.
SC2034: The variable __invocation is indeed unused, but it's supposed
to be there in case the script using bash3boilerplate wants to use it,
so this commit silences the warning.
SC1102: The warning about the parsing of $((( is legitimate, so the
suggested fix is implemented.
SC2015: While the warning is correct in general, here 'true' has no
side effects hence it can be silenced.
Fixes#107.
* Fix shifting over `--`: don't throw errexit
Fixes#21
* Add error trapping (including Ctrl-C) info to FAQ
Closes#47
* Add backtracing to help localize errors
- Fixes#44
- Backtracing is turned on when the debugging `-d` flag is passed,
otherwise backtracing function defined but signal trap not set.
- Update main-help fixture due to moving trap
* Untabify main.sh
Might be a controversial move, but I loath tabs...
* Add checks for tab chars and trailing whitespace
- Update poor-man's style enforcement script to check for these
violations
- Better document style guidlines in README with small tweaks
* Add a magic variable to indicate if being source
if `__i_am_main_script=1 #true` then `main.sh` called directly
Fixes#45
moved entries in changelog from `unreleased` to 2.1.0 (even
though technically it's too late for that since that version was already
released).
added new section for 2.2.0 and added some points on what changed.
bumped version to 2.2.0 in main.sh, example.sh and package.json
Closes#74
If the description of an option contains the single word sentence
'Required.' it is understood as a required argument and automatic
validation will make sure that it is set or end the script by calling
help.
Alternatively, if the argument within the __usage string is {arg}
instead of [arg] it is understood as a required argument and automatic
validation will make sure that it is set or end the script by calling
help (even if 'Required.' is not in the description).
Closes#22
turn off colors if NO_COLOR is "true" or TERM is not "xterm*" or STDERR
is not connected to a terminal, but ignore TERM and STDERR if NO_COLOR
is set to "false" explicitly.
Fixes#69
If main.sh is being sourced instead of being executed it respects the
variables __usage and __helptext being defined beforehand. Its behaviour
will depend on the sourcing script. If __usage is defined but empty no
argument parsing is done. If __helptext is defined but empty no helptext
will be shown.
Logging support still exists as it did before. The environment variables
LOG_LEVEL and NO_COLOR are supported just as they were before.
turns out that the README.md explains that "... licensed under MIT ...
the LICENSE does not have to be bundled as long as ..." but the scripts
themselfs don't mention any license.
fixed that by adding a one line mention of the used license and the two
lines explaining that the header comments have to stay intact.
* better logging: support for multiple lines
* renamed logging function from _fmt to __b3bp_log
* adding example to show how multiline logging works
the main idea is to be able to log e.g. the output of a command and
b3bp taking care of splitting and prefixing every line.
* simplified code, removed hacky space-at-EOL
all internally used variable names (e.g. the ones used while parsing
__usage and running the getopts loop) start with '__b3bp_tmp'. This
makes it easy to unset them all after the work is done.
additional bugfix: run getopts only if any options were actually
specified in __usage
* Make the license less restrictive. See #14
So that people can use _just_ main.sh without bothering with also
distributing the license
* Add license update to changelog
* Add a comment about expansion, see #26
* Use an unmodified MIT License, with the more permissive clause inside the code
As modifying the MIT License will needlessly (but rightfully) cause
suspicion
* Credit @bravo-kernel for his feedback
* Fix another typo
* Reword copyright
Fixes problem where long options with dashes, like `--no-color` were
broken. This was due to the fact that bash variable names must match
`[_a-zA-Z][_0-9a-zA-Z]*` and the usage parsing and option handling was
trying to create variables with dashes in their names. Short of
employing Bash4 associative arrays, "name mangling" seemed like the
best solution to this problem.
Solution: map dashes to underscores when creating bash variables in the
script that correspond to long option flags. The downside of this is
that `--no_color` and `--no-color` will collide, but users expecting to
use options that are identical except one has an underscore and the
other has a dash deserve the ensuing confusion.