Commit Graph

66 Commits

Author SHA1 Message Date
539443b3ca Allow for multiline opt description in __usage. Fixes #7 2016-11-11 20:13:01 +01:00
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
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
9928ef16d7 Update version 2016-11-08 13:07:29 +01:00
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
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
35b51072b3 No more os detection (#41) 2016-06-24 13:12:41 +02:00
03a2ec5adf Better OS detection (#39) 2016-06-23 16:20:45 +02:00
818d7c81c7 Return Windows as OS when under Git Bash (?) #32 2016-06-22 09:52:38 +02:00
64488e569a For delete-key-friendliness, bundle the commandline definition block along with its parser 2016-06-21 13:49:11 +02:00
e0aadaf50c Comment each set with a single line 2016-06-21 13:48:37 +02:00
008face7c8 Less verbose header comments 2016-06-21 13:48:08 +02:00
4926bbc942 For delete-key-friendliness, don't crash on undeclared help vars 2016-06-21 13:38:47 +02:00
649b5a0f44 Introduce errtrace, which is on by default (BREAKING) 2016-06-21 13:36:48 +02:00
5ee427eef5 Allow adding a help that is not parsed. See #24 2016-06-21 12:30:12 +02:00
ae230acc3b Add best practice of using __double_underscore_prefixed_vars 2016-06-21 10:21:00 +02:00
18525f72da Make the license less restrictive. See #14 (#28)
* 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
2016-06-20 09:57:31 +02:00
12f1013611 Credit @gdevenyi for his testing and suggestions 2016-06-19 13:17:52 +02:00
d70312e916 Add a comment about expansion, see #26 2016-06-19 13:13:38 +02:00
fc7802d707 Respect --no-color by setting the NO_COLOR flag in main.sh. Fixes #25. thx @gdevenyi 2016-06-19 13:06:53 +02:00
8687e384eb Split out changelog into separate file, credit @rouson for the FAQ 2016-03-03 12:45:07 +01:00
a86d8d82b1 Mangle long-option names to allow dashes
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.
2016-02-19 23:25:09 -05:00
db690268ea Whitespace 2016-02-17 13:46:05 +01:00
366d8c7c9c Update version 2016-02-17 13:41:46 +01:00
67f2eafc81 Update version 2016-02-17 09:53:20 +01:00
c3297e4a7a Better versioning 2016-02-17 09:35:59 +01:00
2019c5146a Upgrade version 2016-02-16 22:23:28 +01:00
d365e8dcea Allow disabling colors via NO_COLOR environment variable 2016-02-16 22:19:40 +01:00
915f858d5e Add __os magic var 2016-02-16 22:19:08 +01:00
cbe70aa80e Put comments on own line 2016-02-16 22:09:28 +01:00
ff907092a3 Document caveats 2016-02-16 22:08:27 +01:00
56721e9cd5 Add test for longopt parsing 2016-02-16 22:05:11 +01:00
df3d535ab1 Make long option parsing work on OSX's BSD awk 20070501 2016-02-16 21:59:38 +01:00
2196cc4411 Add __base magic var 2016-02-16 21:58:25 +01:00
90ad85f419 Port back more refined colorscheme from @arathai's fork 2016-02-16 21:24:41 +01:00
9935335ee8 Add @zbeekman as an author 2016-02-16 20:53:59 +01:00
bfb8d40f6c Enable long, GNU style options
- 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
2016-02-16 14:39:10 -05:00
ecd6a9f04b Easier testing on travis 2016-02-16 15:48:48 +01:00
f2e8ff236a Add clarifications 2015-11-11 16:10:35 +01:00
23b68a1bfc Update main.sh
Fix super trivial typo
2015-02-19 19:51:00 -05:00
5b8cf352c8 Use BASH_SOURCE[0] 2014-11-11 12:41:18 +01:00
752036320a Update main.sh 2014-07-29 17:32:23 +02:00
e2602f6a58 Merge branch 'master' of github.com:kvz/bash3boilerplate
Conflicts:
	main.sh
2014-07-23 11:34:05 +02:00
af23876cd1 Bump version 2014-07-23 11:31:42 +02:00
e5af9cf01b Consistent use of longhand options 2014-07-23 11:31:34 +02:00
7304249545 Whitespace 2014-07-23 11:31:17 +02:00
17e7677757 Shrink boilerplate function 2014-07-23 11:30:53 +02:00
3f8ac03553 Color support for more xterms 2014-07-23 11:30:33 +02:00
667bfd7350 Localize function vars 2014-07-23 11:30:09 +02:00
5e492a419c DIR and FILE are actually local vars, so lowercase
Also improve pathfinding to not rely on readlink, and to work as
expected when file is sourced
2014-07-23 11:29:42 +02:00