Current

Release v0.5.0 - Basic yet adaptable configuration

Next

Release v0.6.0 - Better argument parsing

Release v0.5.0 - Basic yet adaptable configuration

The latest release of JCLI has been released, featuring a very basic yet moderately adaptable configuration service.

This post also serves as a test of how I plan to format any future 'release' or 'changelog' style posts.

Changes

The following changes were implemented:

  1. Feature - Add IConfig, AdaptableFileConfig, and AsdfAdapter
  2. Feature - Add functions such as underline, bold, etc. to AnsiText
  3. Feature - Add UserIO.exception line of logging functions (e.g. UserIO.logException).
  4. Breaking change - The members of the Ansi4Bit enum now use camelCase instead of PascalCase. This is simple enough to fix however.
  5. Testing - The example runner can now test that an example's output matches a regex.

Config Service

A common action that a command line application needs to perform, is the ability to create, store, and load configuration files.

To lower the barrier of entry for creating, or even prototyping a CLI application using JCLI, this release provides a simple interface used to serialise and deserialise data, while allowing commands to be free of the burden or technical aspects of having to manage their configuration files.

An example can be seen here.

Brief overview

IConfig is the core interface, which is what commands should be injected with, using JCLI's support for dependency injection.

Adapters are types that provide a static serialise and deserialise function, they are used by "adaptable" IConfig implementations to allow the user to choose the underlying serialisation library.

This release ships with an adapter for the asdf library.

AdaptableFileConfig is an adaptable IConfig that uses the file system to store the configuration value, serialised using whichever adapter you pass to it.

AnsiText additions

AnsiText now has support for the following ANSI codes:

  • Bold
  • Dim
  • Italic
  • Underline
  • Slow Blink
  • Rapid Blink
  • Invert
  • Strike

Of course, it'll be down to the individual terminal to support each of these features. In general though, if it's supported in Windows' command line, it's supported everywhere else.

Here is an screenshot from the new Windows Terminal, emulating powershell:

Ansi text additions

UserIO Exception Logging

There's a relatively common situation where your program needs to display an exception in detail, but doesn't want to leave the exception uncaught just to display this information (i.e. keep the program running even on exception).

So, UserIO now have the exception range of logging function (UserIO.logException, verboseException, and debugException) which can be used to easily display the information of an exception.

Here's an example from JCLI's configuration example:

UserIO.verboseException

Reminder

In the event that there's actually someone else other than me that uses this library, I'd just like to remind you that I'm completely open to suggestions, criticism, PRs, etc.