Release v0.9.0 - Bash completion and ArgBinder validation
The latest release of JCLI has been released, mainly featuring new validation capabilities for ArgBinder.
The following changes were implemented:
- Feature - Preliminary support for automatic Bash Completion.
- Feature - Add ability for
ArgBinderto also perform validation using user-provided UDAs.
- Feature - Add
asLineWrappedas a lazy, range-based alternative to
- Improvement - Improve
ArgBinder's compile-time debugging.
- Improvement - The example tester has been improved.
- Change - For better or for worse,
ArgPullParsernow allows named arguments to not actually have names.
- Tweak - Improved
CommandLineInterface's internal structure.
- Fix - Fix
UserIO.getInput, it should actually compile now.
- Fix -
HelpTextBuilderTechnicalshould no longer output more new lines than needed.
JCLI now has intial support for providing Bash command line completion.
At the moment, there is no real user-facing customisation that is possible, but it's definitely something I'd like to have in the future.
Here is an example of the bash completion, using the JCLI Test Project:
This particular example uses the
eval command to interpet the bash completion script, but you can use whatever mechanism is
best for you to enable completion.
The script for any program can be obtained by passing
__jcli:bash_complete_script as the command name to any JCLI program.
ArgBinder can now also perform validation, both on the input string as well as the final bound output.
While the example
shows you basic usage (when using
CommandLineInterface as your core), the TLDR is:
- Create a struct with either or both of these signatures:
// This can be templated as well :) bool onValidate(AnyTypeYouWant boundOutput, ref string error); bool onPreValidate(string inputString, ref string error);
On error, return
falseand populate the
errorstring, otherwise return
Attach your struct as a UDA onto any
CommandLineInterfacewill handle the rest.
If a validator cannot be used with the argument it's attached to, then
ArgBinder will silenty pass over it.
If you want
ArgBinder to throw compiler errors when instead of ignoring things, such as for figuring out why it happens,
then define the