Move SHELLFU_DEBUG* and SHELLFU_VERBOSE to pretty where they belong
These variables are not specific to shellfu internals but in all ways
specific to pretty.sh module. The prefix is mostly historical cruft.
Let's clean that up.
Old naming is inconsistent from how functions are named, which can be
pretty confusing.
Also, there's no such naming requirement for user's modules; the
recommended way is to use unique project-specific prefix for both
functions and globals.
Risk of conflict should be managed by naming modules uniquely and/or
being careful with deployment in new environments.
Main changes:
* Removed ability to guess, search and merge files.
Old inigrep was doing too much. Instead of just being "grep for
INIs", it tried to guess file arguments, look for data in local
folders and smartly merge files based on locality, effectively
becoming sort of a configuration registry tool. While that function
can be (and was) highly useful, it is vastly outside inigrep's main
purpose; coupling like this made inigrep much harder to understand.
At the same time, only saturnin applications really used this;
so it became obvious where such behavior belongs, so relevant
code was moved to saturnin__conf, which now acts as wrapper around
the new inigrep.
* Rewrote API.
Old API was designed around the original idea, long long time ago,
when use cases were not clear yet. This fact propagates as the old
API being a bit gimmicky, too "granular" with little usability gain
but great graspability loss.
New API, on the other hand, simplifies section/key syntax and
concentrates on few simple modes, easy to understand and/or ignore.
* Added module-level documentation.
Now that shellfu-doc can work as manpage reader, it would be shame
to not include at least some basic documentation inside modules.
inigrep (albeit being one-function module) is proud to be the first
one in shellfu core module set to have at least simple introduction.
Great rewrite with revamped CLI, many added features and bugfixes.
* New CLI optimized for simple use. Default action is to show
module doc in manpage viewer.
* Respects variable documentation.
* Respects module documentation (first stray docstring).
* Can export (ugly but usable) module docs as Markdown, POD or
manpage.
* Dropped useless features as --cat (one can always open the file)
or display of partial documentation.
* Provided more rich usage hint.
* Rewrote tests with focus on more probable scenarios.
Use declare builtin to generate debug output.
We gain support for all Bash types, declare will do the formatting for
us, plus we can easily cover Unset state.
We needed to improve TF_RUN for this to work properly:
* fixup wrapping so that shebang, which influences
detection of SHELLFU_COMPAT, comes first (if there is one),
* and call the test script directly for the shebang to matter
(i.e. do not force `bash` in Bash mode upon all).
Although normally we prefer to sat "result must look like oracle",
that is, have result on RHS, and oracle on LHS of a comparison, with
udiff this produces far more readable result, e.g.:
--- oracle/try_import_fn.new
+++ result/try_import_fn.new
-foo
if foo was expected but is missing,
--- oracle/try_import_fn.new
+++ result/try_import_fn.new
+bar
if bar came unexpected.
shellfu-get (whose only job is to print one of hardcoded strings depending
on $1) and shellfu.sh should be as light as possible. Most of this code
is only useful (and intended) for library exploration, which is domain
of shellfu-doc.
A neat side-effect is, that in its new home, we don't have to be so
fussy about performance and footprinting, so we can afford luxury such
as putting code into functions and documenting them, using $1 for first
argument, using shellfu libraries(!)...
Needless to say, this is an incompatible CLI change (or it would have
half the effect), so we take the opportunity to re-do the CLI to match
the new home.
Remove '()' decoration from $caller internal variable. Decorations are
matter of presentations; at this level the brackets are only confusing.
To decide whether a caller is main script or direct descendant thereof,
called main(), use negative index of the stack array FUNCNAME (0 in first
case, 1 in the second). To signal that to the `_pretty_*` plug-ins,
use a dedicated boolean.
This also accounts for cases when a main() function is declared somewhere
else than in the main binary. Older code would simply assume (based
on the name being "main") that it's called from main binary and rewrite
$caller, possibly causing confusion. Now, only the originally intended
special cases behave specially.
This is simply impossible; debug_pipe is wrapper around debug which is
identified soon enough, so "debug_pipe" can't be assigned to $frontend.
Also, _pretty__get_frontend() will never return bracket-decorated
function name.
Do not exclude empty lines when debugging with debug_pipe
The grep throws away all empty lines, no matter if SHELLFU_DEBUG is on
or not.
This seems as terrible idea and I can't find out what wass the reason for
that. (I wonder why everything is not broken due to this; most probably
because nobody really uses debug_pipe.)
Do not exclude anything just if debug is on and caller fits
The exclusion criterion would be true for amy frontend just if debug
was on and the caller fit SHELLFU_DEBUG_EXCLUDE. That is, even warnings
and thoughts from the caller would be muted!
In fact, it's frontend that matters; only debug frontend should be
considered for exclusion. OTOH, we don't need to check SHELLFU_DEBUG as
debug frontends already give up ASAP if that is not set.
We also need to move the frontend rewrite sooner for this to work.
It's rather useless in load-time, since the environment is often
tailored since then (e.g. SHELLFU_PATH is the most obvious example).
By far most realistic use case is import; even those related sub-commands
are always used along with import anyway.