structured-cli: Application library for building interactive console CLIs

[ bsd3, console, library, program ] [ Propose Tags ]

This module provides the tools to build a complete "structured" CLI application, similar to those found in systems like Cisco IOS or console configuration utilities etc. It aims to be easy for implementors to use.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
debug

Enable debug messages

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.9.0.2, 0.9.0.3, 0.9.1.0, 0.9.2.0, 0.9.3.0, 0.9.3.1, 0.9.4.0, 0.9.4.1, 2.0.0.0, 2.0.0.1, 2.2.0.0, 2.2.1.0, 2.3.0.0, 2.4.0.0, 2.4.0.1, 2.5.0.0, 2.5.0.1, 2.5.0.2, 2.5.0.3, 2.5.1.0, 2.5.2.0, 2.6.0.0, 2.7.0.0, 2.7.0.1
Dependencies base (>=4.9.1.0 && <5), data-default (>=0.7.1.1 && <0.8), exceptions (>=0.6 && <0.11), haskeline (>=0.8 && <0.9), mtl (>=2.2.1 && <3.0), split (>=0.2.3.2 && <0.3), structured-cli, transformers (>=0.5.2.0 && <0.6) [details]
License BSD-3-Clause
Copyright 2017 Erick Gonzalez
Author Erick Gonzalez
Maintainer erick@codemonkeylabs.de
Category Console
Home page https://gitlab.com/codemonkeylabs/structured-cli#readme
Bug tracker https://gitlab.com/codemonkeylabs/structured-cli/issues
Source repo head: git clone https://gitlab.com/codemonkeylabs/structured-cli
Uploaded by erick at 2020-12-17T13:00:08Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables some-cli
Downloads 11056 total (50 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-12-17 [all 1 reports]

Readme for structured-cli-2.7.0.1

[back to package description]

structured-cli

Haskell library for building structured CLI applications

This module provides the tools to build a complete "structured" CLI application, similar to those found in systems like Cisco IOS or console configuration utilities etc. It aims to be easy for implementors to use.

  • How to use this module:

It is often the case that a simple example is the best user guide, at least for the experienced programmer. The following code illustrates a basic but functioning CLI application:

module Main where

import Control.Monad                 (void)
import Control.Monad.IO.Class        (liftIO)
import Data.Default                  (def)
import System.Console.StructuredCLI

root :: Commands ()
root = do
  world >+ do
    hello
    bye
    command "exit" "return to previous level" exit

world :: Commands ()
world = command "world" "enter into the world" $ return NewLevel

hello :: Commands ()
hello = command "hello" "prints a greeting" $ do
          liftIO . putStrLn $ "Hello world!"
          return NoAction

bye :: Commands ()
bye = command "bye" "say goodbye" $ do
        liftIO . putStrLn $ "Sayonara!"
        return NoAction

main :: IO ()
main = void $ runCLI "Hello CLI" def root

resulting example session:

>>> Hello CLI > ?
- world: enter into the world

>>> Hello CLI > world
>>> Hello CLI world > ?
- exit: return to previous level
- bye: say goodbye
- hello: prints a greeting

>>> Hello CLI world > hello
Hello world!
>>> Hello CLI world > bye
Sayonara!
>>> Hello CLI world > exit
>>> Hello CLI >

A good way to get you started is to grab the example code available under example/Main.hs and modify it to suit your needs.