cli4clj 1.2.0 Released

This is a brief post to announce the release of version 1.2.0 of cli4clj, a small library for easing the creation of interactive command line interfaces (CLIs). The most noteworthy changes in this version are:

  • Addition of a run-time setting to print full traces of exceptions instead of just printing the exception message.
  • Fallback to String representation for elements that would otherwise cause a RuntimeException due to invalid tokens.
  • Addition of a “print” command for the example application.

The “enable-trace true” run-time setting, which defaults to “false”, enables printing of the full traces of exceptions instead of just printing the exception message. In the following listing a somewhat shortened example is shown:

cli# enable-trace false
print-exception-trace is set to: false
cli# d 1 0
Divide by zero
cli# enable-trace true
print-exception-trace is set to: true
cli# d 1 0
java.lang.ArithmeticException: Divide by zero
 at clojure.lang.Numbers.divide (
 cli4clj.example$divide.invokeStatic (example.clj:21)
 cli4clj.example$divide.invoke (example.clj:20)

Some input values, e.g., “/foo/bar” would cause an exception due to an invalid token. In version 1.2.0, I added a fallback, that returns the String representation in such cases instead of failing with an exception. The fallback can be disabled by setting the cli4clj configuration setting “:invalid-token-to-string” in the options map to false.

Last but not least, a “print” function was added to the example application. The print function serves two purposes. It pretty prints its arguments including the type of the first argument. This is, e.g., intended for getting an understanding of what data types cli4clj uses for what input. In addition, the print command shows the use of optional arguments.

Some known issues and things that I may improve in the future, as my time permits it, are, e.g.: the full stack trace is printed to stdout instead of stderr because of some strange behavior I had here on my development machine. The setting for switching between full stack trace vs. short exception message output uses a global atom var, for now. I plan to refactor that in future.

I hope that you consider these changes useful. As usual, feedback and comments are always appreciated.

This entry was posted in cli4clj, Libs. and tagged , , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.