Commit Graph

103 Commits

Author SHA1 Message Date
Kevin van Zonneveld
f6b61410c0
Update version 2023-08-29 12:44:42 +02:00
Kevin van Zonneveld
14421bd791
Update version 2023-08-29 12:44:13 +02:00
Kevin van Zonneveld
320609fceb
update version 2023-08-29 12:44:10 +02:00
Kevin van Zonneveld
9e70d61133
Fix improper replace 2023-08-29 12:43:49 +02:00
Kevin van Zonneveld
2d145e24e9
Update version 2023-08-29 12:37:51 +02:00
FilipBrinkmann
e45247d4aa
Fix duplicated comment (#166) 2023-07-05 22:21:11 +02:00
Kevin van Zonneveld
febd9e354b
Switch from using Travis to GitHub Actions (#141)
* First swing at GHA

* Delete .travis.yml

* Update ci.yml

* Update main.sh

* Update ci.yml

* Update ci.yml
2020-11-23 19:56:46 +01:00
Gert Goet
599faf3830 Correct error_code in err_report (#124) (#125) 2019-11-18 11:56:18 +01:00
Kevin van Zonneveld
24e7ceaaf7 Update version 2019-11-07 14:23:58 +01:00
Kevin van Zonneveld
c0f58127bb Update version 2019-11-07 14:23:26 +01:00
Kevin van Zonneveld
bccefb0061 Update version 2019-11-07 14:21:46 +01:00
Kevin van Zonneveld
f77b400dc9 Fix main-repeated tests, flags weren't incremented before 2019-10-29 10:43:47 +01:00
Kevin van Zonneveld
b8a4aba3c2 Allow outputting both flags and arrays for arg_i and arg_x
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
2019-10-29 09:57:59 +01:00
Kevin van Zonneveld
4085bc461e -v operator was added in bash 4.2 while we target bash 3 2019-10-29 08:34:52 +01:00
gmeral
ea57d157c7 #111 more contrasted colors for alert and emergency (#112)
* Set alert and emergency colors to more readable values

* Add entry to CHANGELOG.md about #111
2019-09-20 11:43:30 +02:00
Lukas Stockner
95b9cb1469 Add support for repeatable arguments (#118)
* 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
2019-09-20 11:40:06 +02:00
Lukas Stockner
664e55ad1e Fix or silence remaining warnings with shellcheck v0.7.0 (#117)
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.
2019-09-20 11:30:59 +02:00
QwertyZW
7b7d31a1bf Improve debug mode (#103)
Add file, line number, function name and function line offset
2019-05-06 10:04:09 +02:00
Manuel Streuhofer
ba0e7150cb close issue #108 (#109)
* added test for issue-108

* Closes #108

* fixed some easy shellcheck complaints

* trying to fix travis/debian-sid/shellcheck problem
2018-09-03 12:00:55 +02:00
Gabriel A. Devenyi
2048e4303e Add || true to fix __invocation with no arguments (#102) 2018-06-26 15:55:16 +02:00
Gabriel A. Devenyi
327cba75c9 Add magic variable that stores the full command line invocation (#99)
Provides variable __invocation which contains the command line
with proper separators maintained.

Adapted from https://stackoverflow.com/a/36625791
2018-06-06 15:28:55 +02:00
A. G. Madi
2463cd6cc9 Allow counting how many times an argument is used. (#96)
An example of use would be the passing in of multiple -v options in some utilities to increase verbosity.
2018-01-22 15:21:48 +01:00
Manuel Streuhofer
236e3c7eca fix shellcheck errors
shellcheck 0.4.7 seems to have come up with new checks and now complains
about yet more possible issues. fixed them all as good as i could.
2018-01-21 23:02:03 +01:00
Germain Masse
12ea4dd75f
Enable color in screen or tmux 2017-08-13 21:08:59 +02:00
Izaak Beekman
cb29b2f984
Restore @mstreuhofer's changes that I clobbered 2017-02-10 19:00:00 -05:00
Izaak Beekman
0d1f488365
Fix shellchk and show usage for new magic var
Update acceptance tests
2017-02-10 18:58:35 -05:00
Manuel Streuhofer
d879ae1fe0 fixup example.sh like 2.3.0 main.sh
__i_am_main_script logic fixed for example.sh
added double-sourced test
2017-02-10 20:40:38 +01:00
Kevin van Zonneveld
382217eebf Update version 2017-02-10 15:32:48 +01:00
Izaak Beekman
7cf9ea708d Issue 44 issue 21 issue 47 (#85)
* 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
2017-02-10 15:03:07 +01:00
Manuel Streuhofer
d383e8c098 prepared changelog for release 2.2.0 (#82)
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
2016-12-21 09:29:02 +01:00
Manuel Streuhofer
cf85af8c15 brace all variables, used [[ instead of [ (#76)
Closes #33
2016-12-14 09:54:25 +01:00
Manuel Streuhofer
9350e0574c added automatic usage validation for required args
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
2016-12-09 00:54:52 +01:00
Manuel Streuhofer
1e69fd5e21 removed all usage of eval, proper usage of unset
replaced all `eval` with `printf -v` for security reasons.

the behaviour of unset without -v/-f is actually undefined so make the
intent clear.
2016-12-06 18:06:25 +01:00
Izaak Beekman
68323978d4 Merge pull request #70 from mstreuhofer/color
Fix auto-color-off code

 Thanks to @mstreuhofer for another great contribution 🎊 🙇
2016-12-05 12:37:28 -05:00
Manuel Streuhofer
b8bdaf371a get rid of awk, sed & egrep usage 2016-12-03 18:52:40 +01:00
Manuel Streuhofer
290c65d4b9 fix auto-color-off code
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
2016-12-03 18:52:10 +01:00
Manuel Streuhofer
9b739b4cf0 Fix some code caught by shellcheck (#68) 2016-12-01 14:40:56 +01:00
Manuel Streuhofer
539443b3ca Allow for multiline opt description in __usage. Fixes #7 2016-11-11 20:13:01 +01:00
Manuel Streuhofer
dfd799b4e5 b3bp sourced mode (#61)
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.
2016-11-09 10:03:00 +01:00
Manuel Streuhofer
d2195eee3c mention the used license in each script header (#60)
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.
2016-11-08 21:15:46 +01:00
Kevin van Zonneveld
9928ef16d7 Update version 2016-11-08 13:07:29 +01:00
Manuel Streuhofer
f82bbe59b0 better logging. support for multiple lines. (#57)
* 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
2016-11-08 13:03:26 +01:00
Manuel Streuhofer
4445c181bb cleanup environment variables (#58)
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
2016-11-08 13:02:37 +01:00
Kevin van Zonneveld
35b51072b3 No more os detection (#41) 2016-06-24 13:12:41 +02:00
Kevin van Zonneveld
03a2ec5adf Better OS detection (#39) 2016-06-23 16:20:45 +02:00
Kevin van Zonneveld
818d7c81c7 Return Windows as OS when under Git Bash (?) #32 2016-06-22 09:52:38 +02:00
Kevin van Zonneveld
64488e569a For delete-key-friendliness, bundle the commandline definition block along with its parser 2016-06-21 13:49:11 +02:00
Kevin van Zonneveld
e0aadaf50c Comment each set with a single line 2016-06-21 13:48:37 +02:00
Kevin van Zonneveld
008face7c8 Less verbose header comments 2016-06-21 13:48:08 +02:00
Kevin van Zonneveld
4926bbc942 For delete-key-friendliness, don't crash on undeclared help vars 2016-06-21 13:38:47 +02:00