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]
Versions [faq] 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
Dependencies base (>=4.9.1.0 && <4.12), data-default (>=0.7.1.1 && <0.8), haskeline (>=0.7.4.0 && <0.8), 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
Revised Revision 4 made by erick at Mon Dec 30 21:40:07 UTC 2019
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 Thu Nov 22 19:19:28 UTC 2018
Distributions NixOS:2.6.0.0, Stackage:2.5.1.0
Executables some-cli
Downloads 7294 total (756 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2018-11-22 [all 1 reports]

Modules

[Index] [Quick Jump]

Flags

NameDescriptionDefaultType
debug

Enable debug messages

DisabledAutomatic

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

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for structured-cli-2.5.0.0

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