simple-cmd-args-0.1.1: Simple command args parsing and execution

Safe HaskellSafe
LanguageHaskell2010

SimpleCmdArgs

Description

This library provides a thin layer on optparse-applicative argument and option parsing, using Parser (IO ()), applying commands directly to their argument parsing.

A few option Mod functions are also provided.

Synopsis

Documentation

simpleCmdArgs Source #

Arguments

:: Maybe Version

version string

-> String

header

-> String

program description

-> Parser (IO ())

commands

-> IO () 

Parser executor (allows interspersed args and options)

simpleCmdArgs (Just version) "summary" "program description" $ myCommand <$> myOptParser <*> myargsParser

simpleCmdArgs' Source #

Arguments

:: Maybe Version

version string

-> String

header

-> String

program description

-> Parser (IO ())

commands

-> IO () 

Parser executor without interspersing options and args

simpleCmdArgs' Nothing "summary" "program description" $ myCommand <$> myOptParser <*> myargsParser

simpleCmdArgsWithMods Source #

Arguments

:: Maybe Version

version string

-> InfoMod (IO ())

modifiers

-> Parser (IO ())

commands

-> IO () 

Generic parser executor with explicit info modifiers

data Subcommand Source #

Subcommand "command" "help description text" $ myCommand <$> optParser

Constructors

Subcommand String String (Parser (IO ())) 

subcommands :: [Subcommand] -> Parser (IO ()) Source #

list of Subcommand that can be run by simpleCmdArgs

strArg :: String -> Parser String Source #

A string arg parser with a METAVAR for help

switchWith :: Char -> String -> String -> Parser Bool Source #

switch with Mods

switchWith 'o' "option" "help description"

switchMods :: HasName f => Char -> String -> String -> Mod f a Source #

Mods for a switch.

switchMods 'o' "option" "help description"

strOptionWith :: Char -> String -> String -> String -> Parser String Source #

strOption with Mods

strOptionWith 'o' "option" "METAVAR" "help description"

optionWith :: ReadM a -> Char -> String -> String -> String -> Parser a Source #

option with Mods

optionWith 'o' "option" "METAVAR" "help description"

optionMods :: (HasMetavar f, HasName f) => Char -> String -> String -> String -> Mod f a Source #

Mods for a mandatory option.

optionMods 'o' "option" "METAVAR" "help description"

strOptionalWith :: Char -> String -> String -> String -> String -> Parser String Source #

strOptional with Mods

strOptionalWith 'o' "option" "METAVAR" "help description" default

optionalWith :: ReadM a -> Char -> String -> String -> String -> a -> Parser a Source #

optional option with Mods, includes a default value.

optionalWith 'o' "option" "METAVAR" "help description" default

optionalMods :: (HasMetavar f, HasName f, HasValue f) => Char -> String -> String -> String -> a -> Mod f a Source #

Mods for an optional option: includes a default value.

optionalMods 'o' "option" "METAVAR" "help description" default

argumentWith :: ReadM a -> String -> Parser a Source #

argument with METAVAR

argumentWith auto "METAVAR"