Create simple interactive CLIs for Clojure applications.
HTML Clojure JavaScript Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Create simple interactive CLIs for Clojure applications.

Clojars Project Build Status Coverage Status


The aim of cli4clj is to allow the quick and effortless creation of interactive command line interfaces (CLIs). Features of cli4clj are:

  • Simple configuration via maps
  • Command line history
  • Command line editing
  • Tab-completion
    • For command names
    • Hints for selected commands: based on function arguments and custom hints
  • Aliases can be used to define alternative command names, e.g., for shortcuts.
  • Clojure data types, e.g., vector, list, map, etc., can be used as command arguments.
  • Build-in help
  • Customizable, similar to the Clojure REPL
  • Functionality for testing CLIs via unit tests

On my website I wrote some posts about cli4clj in which you can find more verbose information.


See for a usage example.

The given example can be run via "lein run".

Below is an example output that shows running the usage example:

~/r/p/c/cli4clj (master=) lein run
cli# help
add [a]
    Add two values.  Arguments: [[summand1 summand2]]

divide [d]
    Divide two values.   Arguments: [[numer denom]]
    The first argument will be divided by the second argument.

help [?]
    Show help.
    Display a help text that lists all available commands including further detailed information about these commands.

quit [q]
    Quit the CLI.
    Terminate and close the command line interface.

test [h t]
    Test Command
    Prints a test message to stdout.

    Seq to CSV   Arguments: [[data]]
    E.g.: "to-csv [1 2 3]"

cli# test
This is a test.
cli# t
This is a test.
cli# add 1 2
cli# ; Example for an error due to wrong number of arguments.
cli# add 1 2 3
Wrong number of args (3) passed to: example/-main/fn--168
cli# ; Example for an error due to exception in function.
cli# divide 1 0
Divide by zero
cli# d 4 2
cli# d 4 3
cli# ; Example to show the use of complexer data types, here, a vector and a list.
cli# to-csv [1 7 0 1]
cli# ; Note that the list is not quoted.
cli# to-csv (1 8 6 4)
cli# ; Examples of tab-completion.
cli# TAB
?        a        add      d        divide   e        exit     h        help     q        quit     t        test     to-csv   
cli# add TAB
Arguments: [[summand1 summand2]]                                      
cli# add 1 2
cli# diTAB
cli# divide TAB
Arguments: [[numer denom]]   Divide two values.                                        
cli# divide 1 3
cli# to-csv TAB
Arguments: [[data]]                                                                                                     
The data argument can be of any Clojure sequence type, e.g., [1 2 3] or (:a :b :c). Note that the list is not quoted.   

cli# to-csv [1 2 3]
cli# q
~/r/p/c/cli4clj (master=) lein run

For examples how the testing functionality can be used please see the test cases in:

API docs can be found at:

Detailed Test Results

Detailed unit test results are avilable at:


Copyright © 2015 Ruediger Gad

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.