The structured-cli package

[ Tags: 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]

Properties

Versions 0.9.0.2, 0.9.0.3, 0.9.1.0, 0.9.2.0, 0.9.3.0
Dependencies base (>=4.7 && <5), data-default, haskeline, mtl, split, structured-cli, transformers [details]
License BSD3
Copyright 2017 Erick Gonzalez
Author Erick Gonzalez
Maintainer erick@codemonkeylabs.de
Category Console
Home page https://github.com/erickg/structured-cli#readme
Source repository head: git clone https://github.com/erickg/structured-cli
Uploaded Wed Sep 6 19:11:43 UTC 2017 by erick
Distributions NixOS:0.9.3.0
Executables some-cli
Downloads 94 total (74 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-09-06 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for structured-cli-0.9.3.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:

The following code illustrates a simple but complete CLI app:

import Control.Monad.IO.Class (liftIO)
import System.Console.StructuredCLI

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

world :: Commands ()
world = command "world" (Just "enter into world") Nothing

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

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

main :: IO ()
main = runCLI "Hello CLI" Nothing root

resulting example session:

Hello CLI > ?
- world: enter into world
Hello CLI > world
Hello CLI world >
bye    exit   hello
Hello CLI world > hello
Hello world!
Hello CLI world > exit

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.