stack-1.3.2: The Haskell Tool Stack

Safe Haskell | None
Language | Haskell2010

Options.Applicative.Builder.Extra

Description

Extra functions for optparse-applicative.

Synopsis

- boolFlags :: Bool -> String -> String -> Mod FlagFields Bool -> Parser Bool
- boolFlagsNoDefault :: String -> String -> Mod FlagFields Bool -> Parser Bool
- maybeBoolFlags :: String -> String -> Mod FlagFields (Maybe Bool) -> Parser (Maybe Bool)
- firstBoolFlags :: String -> String -> Mod FlagFields (Maybe Bool) -> Parser (First Bool)
- enableDisableFlags :: a -> a -> a -> String -> String -> Mod FlagFields a -> Parser a
- enableDisableFlagsNoDefault :: a -> a -> String -> String -> Mod FlagFields a -> Parser a
- extraHelpOption :: Bool -> String -> String -> String -> Parser (a -> a)
- execExtraHelp :: [String] -> String -> Parser a -> String -> IO ()
- textOption :: Mod OptionFields Text -> Parser Text
- textArgument :: Mod ArgumentFields Text -> Parser Text
- optionalFirst :: Alternative f => f a -> f (First a)
- absFileOption :: Mod OptionFields (Path Abs File) -> Parser (Path Abs File)
- relFileOption :: Mod OptionFields (Path Rel File) -> Parser (Path Rel File)
- absDirOption :: Mod OptionFields (Path Abs Dir) -> Parser (Path Abs Dir)
- relDirOption :: Mod OptionFields (Path Rel Dir) -> Parser (Path Rel Dir)
- eitherReader' :: Show e => (String -> Either e a) -> ReadM a

# Documentation

boolFlags #

Arguments

:: Bool | Default value
-> String | Flag name
-> String | Help suffix
-> Mod FlagFields Bool |
-> Parser Bool |

Enable/disable flags for a `Bool`.

boolFlagsNoDefault #

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 `<|>`).

maybeBoolFlags #

Arguments

:: String | Flag name
-> String | Help suffix
-> Mod FlagFields (Maybe Bool) |
-> Parser (Maybe Bool) |

Enable/disable flags for a `(`Maybe` `Bool`)`.

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

Like `maybeBoolFlags`, but parsing a `First`.

enableDisableFlags #

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 #

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 #

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 #

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.

textOption :: Mod OptionFields Text -> Parser Text #

`option`, specialized to `Text`.

textArgument :: Mod ArgumentFields Text -> Parser Text #

`argument`, specialized to `Text`.

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

Like `optional`, but returning a `First`.

absFileOption :: Mod OptionFields (Path Abs File) -> Parser (Path Abs File) #

relFileOption :: Mod OptionFields (Path Rel File) -> Parser (Path Rel File) #

absDirOption :: Mod OptionFields (Path Abs Dir) -> Parser (Path Abs Dir) #

relDirOption :: Mod OptionFields (Path Rel Dir) -> Parser (Path Rel Dir) #

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

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