commander-cli: A command line argument/option parser library built around a monadic metaphor

[ cli, library, mit, options, parsing, program, system ] [ Propose Tags ]

A command line argument/option parser library built around a monadic metaphor.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.0.1, 0.3.0.0, 0.4.0.0, 0.4.0.1, 0.4.1.1, 0.4.1.2, 0.5.0.0, 0.6.0.0, 0.6.1.0, 0.6.2.0, 0.7.0.0, 0.8.0.0, 0.9.0.0, 0.10.0.0, 0.10.0.1, 0.10.1.0, 0.10.1.1, 0.10.1.2, 0.10.1.3, 0.10.2.0, 0.11.0.0
Change log CHANGELOG.md
Dependencies base (>=4.12 && <5), bytestring (>=0.8 && <1), commander-cli, directory (>=1.3 && <2), mtl (>=2.2 && <3), process (>=1.6 && <2), text (>=1.2 && <2), unordered-containers (>=0.2 && <1) [details]
License MIT
Copyright 2019 Samuel Schlesinger
Author Samuel Schlesinger
Maintainer sgschlesinger@gmail.com
Category System, CLI, Options, Parsing
Home page https://github.com/SamuelSchlesinger/commander-cli
Bug tracker https://github.com/SamuelSchlesinger/commander-cli/issues
Uploaded by sgschlesinger at 2020-06-21T05:17:27Z
Distributions NixOS:0.11.0.0
Executables task-manager
Downloads 4153 total (68 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-06-21 [all 1 reports]

Readme for commander-cli-0.6.2.0

[back to package description]

Commander CLI

Hackage Build Status

This library is meant to allow Haskell programs to quickly and easily construct command line interfaces which are easy to use, especially as a Haskell user. To begin, I suggest viewing/playing with the task-manager application which comes with this repository. Its usage info is generated as:

usage:
task-manager help
task-manager (required env: TASK_DIRECTORY :: [Char]) edit <task-name :: [Char]>
task-manager (required env: TASK_DIRECTORY :: [Char]) open <task-name :: [Char]>
task-manager (required env: TASK_DIRECTORY :: [Char]) close <task-name :: [Char]>
task-manager (required env: TASK_DIRECTORY :: [Char]) tasks
task-manager (required env: TASK_DIRECTORY :: [Char]) priorities
task-manager (required env: TASK_DIRECTORY :: [Char])

The library is based around the following classes:

class Unrender r where
  unrender :: Text -> Maybe r

This class is what you will use to define the parsing of a type from text and can use any parsing library or whatever you want. Next, we have the class

class HasProgram p where
  data ProgramT p m a
  run :: ProgramT p IO a -> CommanderT State IO a
  hoist :: (forall x. m x -> n x) -> ProgramT p m a -> ProgramT p n a
  invocations :: [Text]

Instances of this class will define a syntactic element, a new instance of the data family ProgramT, as well as its semantics in terms of the CommanderT monad, which is a backtracking monad based on a metaphor to military commanders which retreats upon defeat.