cli4clj 1.4.0 Released – Now with Persistent Command History by Default

cli4clj aims on quickly and effortlessly creating interactive Command Line Interfaces (CLIs) for Clojure applications. It is based on jline2 and the Clojure REPL and tries to provide (hopefully) reasonable abstractions and defaults. Features of cli4clj include, e.g.:

  • simple configuration via maps,
  • automatic setup of jline2 features such as tab completion or persistent command history,
  • possibility to use Clojure data types as command arguments,
  • functionality for testing interactive CLIs,
  • or customizability similar to the Clojure REPL.

For more details, have a look at earlier posts about cli4clj and the cli4clj github repository.
In this post, I briefly announce the newly added persistent command history, which leverages jline2s FileHistory.

Like the other functionality provided by cli4clj, I tried to provide reasonable defaults in order to ease the use of cli4clj. I hope that this somewhat follows the philosophy of some tools I like such as Leiningen or the fish shell.

The default file name for the file in which the command history is stored is based on the name of the namespace in which the CLI is created. The naming scheme is as follows: (str (System/getProperty “user.home”) “/.” *ns* “.history”)

The naming scheme can be overridden by setting the :history-file-name key in the options map passed to start-cli when creating the CLI. When passing :history-file-name, the full path of the history file has to be given as string.

The command line history can be disabled by setting the :persist-history key in the options map to false. For embedded CLIs, the persistent command line history is always disabled as a history does not make sense in this case.

I hope cli4clj is helpful for you. I am always happy to get constructive comments and feedback.

This entry was posted in cli4clj, Libs., Uncategorized 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 )

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.