stack-2.14.0: The Haskell Tool Stack
Safe HaskellSafe-Inferred
LanguageGHC2021

Options.Applicative.Builder.Extra

Description

Extra functions for optparse-applicative.

Synopsis

Documentation

boolFlags Source #

Arguments

:: Bool

Default value

-> String

Flag name

-> String

Help suffix

-> Mod FlagFields Bool 
-> Parser Bool 

Enable/disable flags for a Bool.

boolFlagsNoDefault Source #

Arguments

:: String

Flag name

-> String

Help suffix

-> Mod FlagFields Bool 
-> Parser Bool 

Enable/disable flags for a Bool, without a default case (to allow chaining with <|>).

firstBoolFlagsNoDefault :: String -> String -> Mod FlagFields (Maybe Bool) -> Parser (First Bool) Source #

Flag with no default of True or False

firstBoolFlagsTrue :: String -> String -> Mod FlagFields FirstTrue -> Parser FirstTrue Source #

Flag with a Semigroup instance and a default of True

firstBoolFlagsFalse :: String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse Source #

Flag with a Semigroup instance and a default of False

enableDisableFlags Source #

Arguments

:: a

Default value

-> a

Enabled value

-> a

Disabled value

-> String

Name

-> String

Help suffix

-> Mod FlagFields a 
-> Parser a 

Enable/disable flags for any type.

enableDisableFlagsNoDefault Source #

Arguments

:: a

Enabled value

-> a

Disabled value

-> String

Name

-> String

Help suffix

-> Mod FlagFields a 
-> Parser a 

Enable/disable flags for any type, without a default (to allow chaining with <|>)

extraHelpOption Source #

Arguments

:: Bool

Hide from the brief description?

-> String

Program name, e.g. "stack"

-> String

Option glob expression, e.g. "docker*"

-> String

Help option name, e.g. "docker-help"

-> Parser (a -> a) 

Show an extra help option (e.g. --docker-help shows help for all --docker* args).

To actually have that help appear, use execExtraHelp before executing the main parser.

execExtraHelp Source #

Arguments

:: [String]

Command line arguments

-> String

Extra help option name, e.g. "docker-help"

-> Parser a

Option parser for the relevant command

-> String

Option description

-> IO () 

Display extra help if extra help option passed in arguments.

Since optparse-applicative doesn't allow an arbitrary IO action for an abortOption, this was the best way I found that doesn't require manually formatting the help.

optionalFirst :: Alternative f => f a -> f (First a) Source #

Like optional, but returning a First.

optionalFirstTrue :: Alternative f => f Bool -> f FirstTrue Source #

Like optional, but returning a FirstTrue.

eitherReader' :: Show e => (String -> Either e a) -> ReadM a Source #

Like eitherReader, but accepting any Show e on the Left.