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.
- Enable long, GNU style options, fixes#1
- *CAVEAT* A short option must be preset for every long option;
but every short option need *not* have a long option
- No BASH 4 features were added, works with bash 3 and standard sed and
awk
- `--` is still respected as the separator between options and arguments
- Use `awk` only instead of `awk` and `sed` for parsing short options
from usage string
- Enable errexit, nounset and pipefail at the top