Previous

Release v0.8.0 - asAnsiChars, asAnsiTexts, and just in general: Ansi

Current

Release v0.9.0 - Bash completion and ArgBinder validation

Release v0.9.0 - Bash completion and ArgBinder validation

The latest release of JCLI has been released, mainly featuring new validation capabilities for ArgBinder.

Changelog

The following changes were implemented:

  1. Feature - Preliminary support for automatic Bash Completion.
  2. Feature - Add ability for ArgBinder to also perform validation using user-provided UDAs.
  3. Feature - Add asLineWrapped as a lazy, range-based alternative to lineWrap.
  4. Improvement - Improve ArgBinder's compile-time debugging.
  5. Improvement - The example tester has been improved.
  6. Change - For better or for worse, ArgPullParser now allows named arguments to not actually have names.
  7. Tweak - Improved CommandLineInterface's internal structure.
  8. Fix - Fix UserIO.getInput, it should actually compile now.
  9. Fix - HelpTextBuilderTechnical should no longer output more new lines than needed.

Bash Completion

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:

Bash Completion example

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 Validation

The 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 false and populate the error string, otherwise return true on success.

  • Attach your struct as a UDA onto any @CommandPositionalArg or @CommandNamedArg, and CommandLineInterface will handle the rest.

  • ???

  • Validation, baby.

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 JCLI_BinderCompilerErrors version.