console-program

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

Latest on Hackage:0.4.2.1

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 stackage.org to host generated Haddocks.

BSD3 licensed by Arie Peterson
Maintained by ariep@xs4all.nl

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.

Changes

Changelog

0.4.2.1

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

0.4.2.0

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

0.4.1.0

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

0.4.0.0

  • 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.

0.3.2

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