Interpret the command line and a config file as commands and options

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

BSD3 licensed by Arie Peterson
Maintained by

This library provides a framework to build command line programs.

The constructed program can have several "commands" that provide different modes of operation. Options can be declared to allow fine-tuning of the behaviour of the program. These options are read from the command line when running the program and from a simple configuration file.

Additionally, there is an interactive mode that reads and executes commands from standard input.

Examples of using this library may be found in the Examples directory in the package tarball.

It provides functionality similar to the cmdargs package. Main differences:

  • console-program does not use unsafePerformIO, and tries to give a more haskellish, referentially transparent interface;

  • it allows a full tree of commands, instead of a list, so a command can have subcommands;

  • it parses a configuration file, in addition to the command line arguments.



  • Update dependency on directory package.

  • Update Examples/Full.hs to work with new API

  • Add withNonOptions function to consume any number of non-option arguments.

  • Add the possibility to customize the prompt in interactive mode.
  • Eliminate dependency on unix package on Win32.

  • API change: the Command constructor now takes an extra argument (specifying whether the command can be abbreviated on the command line). The function command can be used instead of the old constructor.
  • Better handling of exceptions in interactive mode.


  • Generalise actions to allow any instance of MonadIO.
comments powered byDisqus