optparse-simple-0.0.1: Simple interface to optparse-applicative

Safe HaskellNone
LanguageHaskell98

Options.Applicative.Simple

Description

Simple interface to program arguments.

Typical usage with no commands:

do (opts,()) <-
     simpleOptions "ver"
                   "header"
                   "desc"
                   (flag () () (long "some-flag"))
                   empty
   doThings opts

Typical usage with commands:

do (opts,runCmd) <-
     simpleOptions "ver"
                   "header"
                   "desc"
                   (pure ()) $
     do addCommand "delete"
                   "Delete the thing"
                   (const deleteTheThing)
                   (pure ())
        addCommand "create"
                   "Create a thing"
                   createAThing
                   (strOption (long "hello"))
   runCmd

Synopsis

Documentation

simpleOptions Source

Arguments

:: String

version string

-> String

header

-> String

program description

-> Parser a

global settings

-> EitherT b (Writer (Mod CommandFields b)) ()

commands (use addCommand)

-> IO (a, b) 

Generate a simple options parser.

simpleVersion :: Version -> Q Exp Source

Generate a string like Version 1.2, Git revision 1234.

$(simpleVersion …) :: String

addCommand Source

Arguments

:: String

command string

-> String

title of command

-> (a -> b)

constructor to wrap up command in common data type

-> Parser a

command parser

-> EitherT b (Writer (Mod CommandFields b)) () 

Add a command to the options dispatcher.