-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utilities and combinators for parsing command line options -- -- optparse-applicative is a haskell library for parsing options on the -- command line, and providing a powerful applicative interface for -- composing them. -- -- optparse-applicative takes care of reading and validating the -- arguments passed to the command line, handling and reporting errors, -- generating a usage line, a comprehensive help screen, and enabling -- context-sensitive bash, zsh, and fish completions. -- -- See the included README for detailed instructions and examples, which -- is also available on github -- https://github.com/pcapriotti/optparse-applicative. @package optparse-applicative @version 0.17.1.0 module Options.Applicative.Help.Levenshtein -- | Calculate the Damerau-Levenshtein edit distance between two lists -- (strings). -- -- This is modified from https://wiki.haskell.org/Edit_distance -- and is originally from Lloyd Allison's paper "Lazy Dynamic-Programming -- can be Eager" -- -- It's been changed though from Levenshtein to Damerau-Levenshtein, -- which treats transposition of adjacent characters as one change -- instead of two. -- -- Complexity O(|a|*(1 + editDistance a b)) editDistance :: Eq a => [a] -> [a] -> Int module Options.Applicative.Help.Pretty type SimpleDoc = SimpleDocStream AnsiStyle putDoc :: Doc -> IO () hPutDoc :: Handle -> Doc -> IO () empty :: Doc char :: Char -> Doc text :: String -> Doc nest :: Int -> Doc -> Doc line :: Doc linebreak :: Doc group :: Doc -> Doc softline :: Doc softbreak :: Doc hardline :: Doc flatAlt :: Doc -> Doc -> Doc renderSmart :: Float -> Int -> Doc -> SimpleDoc align :: Doc -> Doc hang :: Int -> Doc -> Doc encloseSep :: Doc -> Doc -> Doc -> [Doc] -> Doc list :: [Doc] -> Doc tupled :: [Doc] -> Doc semiBraces :: [Doc] -> Doc (<+>) :: Doc -> Doc -> Doc () :: Doc -> Doc -> Doc (<$$>) :: Doc -> Doc -> Doc () :: Doc -> Doc -> Doc hsep :: [Doc] -> Doc vsep :: [Doc] -> Doc fillSep :: [Doc] -> Doc sep :: [Doc] -> Doc hcat :: [Doc] -> Doc vcat :: [Doc] -> Doc fillCat :: [Doc] -> Doc cat :: [Doc] -> Doc punctuate :: Doc -> [Doc] -> [Doc] fill :: Int -> Doc -> Doc fillBreak :: Int -> Doc -> Doc enclose :: Doc -> Doc -> Doc -> Doc squotes :: Doc -> Doc dquotes :: Doc -> Doc parens :: Doc -> Doc angles :: Doc -> Doc braces :: Doc -> Doc brackets :: Doc -> Doc lparen :: Doc rparen :: Doc langle :: Doc rangle :: Doc lbrace :: Doc rbrace :: Doc lbracket :: Doc rbracket :: Doc squote :: Doc dquote :: Doc semi :: Doc colon :: Doc comma :: Doc space :: Doc dot :: Doc backslash :: Doc equals :: Doc black :: Doc -> Doc red :: Doc -> Doc green :: Doc -> Doc yellow :: Doc -> Doc blue :: Doc -> Doc magenta :: Doc -> Doc cyan :: Doc -> Doc white :: Doc -> Doc dullblack :: Doc -> Doc dullred :: Doc -> Doc dullgreen :: Doc -> Doc dullyellow :: Doc -> Doc dullblue :: Doc -> Doc dullmagenta :: Doc -> Doc dullcyan :: Doc -> Doc dullwhite :: Doc -> Doc onblack :: Doc -> Doc onred :: Doc -> Doc ongreen :: Doc -> Doc onyellow :: Doc -> Doc onblue :: Doc -> Doc onmagenta :: Doc -> Doc oncyan :: Doc -> Doc onwhite :: Doc -> Doc ondullblack :: Doc -> Doc ondullred :: Doc -> Doc ondullgreen :: Doc -> Doc ondullyellow :: Doc -> Doc ondullblue :: Doc -> Doc ondullmagenta :: Doc -> Doc ondullcyan :: Doc -> Doc ondullwhite :: Doc -> Doc bold :: Doc -> Doc debold :: Doc -> Doc underline :: Doc -> Doc deunderline :: Doc -> Doc plain :: Doc -> Doc string :: String -> Doc int :: Int -> Doc integer :: Integer -> Doc float :: Float -> Doc double :: Double -> Doc rational :: Rational -> Doc renderCompact :: Doc -> SimpleDoc displayIO :: Handle -> SimpleDoc -> IO () bool :: Bool -> Doc column :: (Int -> Doc) -> Doc nesting :: (Int -> Doc) -> Doc width :: Doc -> (Int -> Doc) -> Doc -- | Overloaded conversion to Doc. -- -- Laws: -- --
    --
  1. output should be pretty. :-)
  2. --
class Pretty a -- |
--   >>> pretty 1 <+> pretty "hello" <+> pretty 1.234
--   1 hello 1.234
--   
pretty :: Pretty a => a -> Doc ann -- | prettyList is only used to define the instance -- Pretty a => Pretty [a]. In normal circumstances -- only the pretty function is used. -- --
--   >>> prettyList [1, 23, 456]
--   [1, 23, 456]
--   
prettyList :: Pretty a => [a] -> Doc ann type Doc = Doc indent :: Int -> Doc -> Doc renderPretty :: Float -> Int -> Doc -> SimpleDoc displayS :: SimpleDoc -> ShowS (.$.) :: Doc -> Doc -> Doc -- | Render flattened text on this line, or start a new line before -- rendering any text. -- -- This will also nest subsequent lines in the group. groupOrNestLine :: Doc -> Doc -- | Separate items in an alternative with a pipe. -- -- If the first document and the pipe don't fit on the line, then -- mandatorily flow the next entry onto the following line. -- -- The (//) softbreak ensures that if the document does fit on the -- line, there is at least a space, but it's possible for y to still -- appear on the next line. altSep :: Doc -> Doc -> Doc -- | Printer hacks to get nice indentation for long commands and -- subcommands. -- -- If we're starting this section over the desired width (usually 1/3 of -- the ribbon), then we will make a line break, indent all of the usage, -- and go. -- -- The ifAtRoot is an interesting clause. If this whole operation is put -- under a group then the linebreak will disappear; then item d -- will therefore not be at the starting column, and it won't be indented -- more. hangAtIfOver :: Int -> Int -> Doc -> Doc module Options.Applicative.Help.Chunk -- | The free monoid on a semigroup a. newtype Chunk a Chunk :: Maybe a -> Chunk a [unChunk] :: Chunk a -> Maybe a -- | Given a semigroup structure on a, return a monoid structure -- on 'Chunk a'. -- -- Note that this is not the same as liftA2. chunked :: (a -> a -> a) -> Chunk a -> Chunk a -> Chunk a -- | Concatenate a list into a Chunk. listToChunk satisfies: -- --
--   isEmpty . listToChunk = null
--   listToChunk = mconcat . fmap pure
--   
listToChunk :: Semigroup a => [a] -> Chunk a -- | Concatenate two Chunks with a space in between. If one is -- empty, this just returns the other one. -- -- Unlike <+> for Doc, this operation has a unit -- element, namely the empty Chunk. (<<+>>) :: Chunk Doc -> Chunk Doc -> Chunk Doc -- | Concatenate two Chunks with a softline in between. This is -- exactly like <<+>>, but uses a softline instead of -- a space. (<>) :: Chunk Doc -> Chunk Doc -> Chunk Doc -- | Concatenate Chunks vertically. vcatChunks :: [Chunk Doc] -> Chunk Doc -- | Concatenate Chunks vertically separated by empty lines. vsepChunks :: [Chunk Doc] -> Chunk Doc -- | Whether a Chunk is empty. Note that something like 'pure -- mempty' is not considered an empty chunk, even though the underlying -- Doc is empty. isEmpty :: Chunk a -> Bool -- | Convert a String into a Chunk. This satisfies: -- --
--   isEmpty . stringChunk = null
--   extractChunk . stringChunk = string
--   
stringChunk :: String -> Chunk Doc -- | Convert a paragraph into a Chunk. The resulting chunk is -- composed by the words of the original paragraph separated by -- softlines, so it will be automatically word-wrapped when rendering the -- underlying document. -- -- This satisfies: -- --
--   isEmpty . paragraph = null . words
--   
paragraph :: String -> Chunk Doc -- | Part of a constrained comonad instance. -- -- This is the counit of the adjunction between Chunk and the -- forgetful functor from monoids to semigroups. It satisfies: -- --
--   extractChunk . pure = id
--   extractChunk . fmap pure = id
--   
extractChunk :: Monoid a => Chunk a -> a -- | Display pairs of strings in a table. tabulate :: Int -> [(Doc, Doc)] -> Chunk Doc instance GHC.Show.Show a => GHC.Show.Show (Options.Applicative.Help.Chunk.Chunk a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Options.Applicative.Help.Chunk.Chunk a) instance GHC.Base.Functor Options.Applicative.Help.Chunk.Chunk instance GHC.Base.Applicative Options.Applicative.Help.Chunk.Chunk instance GHC.Base.Alternative Options.Applicative.Help.Chunk.Chunk instance GHC.Base.Monad Options.Applicative.Help.Chunk.Chunk instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Options.Applicative.Help.Chunk.Chunk a) instance GHC.Base.Semigroup a => GHC.Base.Monoid (Options.Applicative.Help.Chunk.Chunk a) instance GHC.Base.MonadPlus Options.Applicative.Help.Chunk.Chunk module Options.Applicative.Help.Types data ParserHelp ParserHelp :: Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> ParserHelp [helpError] :: ParserHelp -> Chunk Doc [helpSuggestions] :: ParserHelp -> Chunk Doc [helpHeader] :: ParserHelp -> Chunk Doc [helpUsage] :: ParserHelp -> Chunk Doc [helpDescription] :: ParserHelp -> Chunk Doc [helpBody] :: ParserHelp -> Chunk Doc [helpGlobals] :: ParserHelp -> Chunk Doc [helpFooter] :: ParserHelp -> Chunk Doc -- | Convert a help text to String. renderHelp :: Int -> ParserHelp -> String instance GHC.Show.Show Options.Applicative.Help.Types.ParserHelp instance GHC.Base.Monoid Options.Applicative.Help.Types.ParserHelp instance GHC.Base.Semigroup Options.Applicative.Help.Types.ParserHelp module Options.Applicative.Types data ParseError ErrorMsg :: String -> ParseError InfoMsg :: String -> ParseError ShowHelpText :: Maybe String -> ParseError UnknownError :: ParseError MissingError :: IsCmdStart -> SomeParser -> ParseError ExpectsArgError :: String -> ParseError UnexpectedError :: String -> SomeParser -> ParseError -- | A full description for a runnable Parser for a program. data ParserInfo a ParserInfo :: Parser a -> Bool -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Int -> ArgPolicy -> ParserInfo a -- | the option parser for the program [infoParser] :: ParserInfo a -> Parser a -- | whether the help text should contain full documentation [infoFullDesc] :: ParserInfo a -> Bool -- | brief parser description [infoProgDesc] :: ParserInfo a -> Chunk Doc -- | header of the full parser description [infoHeader] :: ParserInfo a -> Chunk Doc -- | footer of the full parser description [infoFooter] :: ParserInfo a -> Chunk Doc -- | exit code for a parser failure [infoFailureCode] :: ParserInfo a -> Int -- | allow regular options and flags to occur after arguments (default: -- InterspersePolicy) [infoPolicy] :: ParserInfo a -> ArgPolicy -- | Global preferences for a top-level Parser. data ParserPrefs ParserPrefs :: String -> Bool -> Bool -> Bool -> Backtracking -> Int -> Bool -> Bool -> Int -> ParserPrefs -- | metavar suffix for multiple options [prefMultiSuffix] :: ParserPrefs -> String -- | automatically disambiguate abbreviations (default: False) [prefDisambiguate] :: ParserPrefs -> Bool -- | always show help text on parse errors (default: False) [prefShowHelpOnError] :: ParserPrefs -> Bool -- | show the help text for a command or subcommand if it fails with no -- input (default: False) [prefShowHelpOnEmpty] :: ParserPrefs -> Bool -- | backtrack to parent parser when a subcommand fails (default: -- Backtrack) [prefBacktrack] :: ParserPrefs -> Backtracking -- | number of columns in the terminal, used to format the help page -- (default: 80) [prefColumns] :: ParserPrefs -> Int -- | when displaying long names in usage and help, use an '=' sign for long -- names, rather than a single space (default: False) [prefHelpLongEquals] :: ParserPrefs -> Bool -- | when displaying subparsers' usage help, show parent options under a -- "global options" section (default: False) [prefHelpShowGlobal] :: ParserPrefs -> Bool -- | Indentation width for tables [prefTabulateFill] :: ParserPrefs -> Int -- | A single option of a parser. data Option a Option :: OptReader a -> OptProperties -> Option a -- | reader for this option [optMain] :: Option a -> OptReader a -- | properties of this option [optProps] :: Option a -> OptProperties data OptName OptShort :: !Char -> OptName OptLong :: !String -> OptName isShortName :: OptName -> Bool isLongName :: OptName -> Bool -- | An OptReader defines whether an option matches an command line -- argument. data OptReader a -- | option reader OptReader :: [OptName] -> CReader a -> (String -> ParseError) -> OptReader a -- | flag reader FlagReader :: [OptName] -> !a -> OptReader a -- | argument reader ArgReader :: CReader a -> OptReader a -- | command reader CmdReader :: Maybe String -> [String] -> (String -> Maybe (ParserInfo a)) -> OptReader a -- | Specification for an individual parser option. data OptProperties OptProperties :: OptVisibility -> Chunk Doc -> String -> Maybe String -> Bool -> Maybe (Doc -> Doc) -> OptProperties -- | whether this flag is shown in the brief description [propVisibility] :: OptProperties -> OptVisibility -- | help text for this option [propHelp] :: OptProperties -> Chunk Doc -- | metavariable for this option [propMetaVar] :: OptProperties -> String -- | what to show in the help text as the default [propShowDefault] :: OptProperties -> Maybe String -- | whether the option is presented in global options text [propShowGlobal] :: OptProperties -> Bool -- | a function to run over the brief description [propDescMod] :: OptProperties -> Maybe (Doc -> Doc) -- | Visibility of an option in the help text. data OptVisibility -- | does not appear in the help text at all Internal :: OptVisibility -- | only visible in the full description Hidden :: OptVisibility -- | visible both in the full and brief descriptions Visible :: OptVisibility data Backtracking Backtrack :: Backtracking NoBacktrack :: Backtracking SubparserInline :: Backtracking -- | A newtype over 'ReaderT String Except', used by option readers. newtype ReadM a ReadM :: ReaderT String (Except ParseError) a -> ReadM a [unReadM] :: ReadM a -> ReaderT String (Except ParseError) a -- | Return the value being read. readerAsk :: ReadM String -- | Abort option reader by exiting with a ParseError. readerAbort :: ParseError -> ReadM a -- | Abort option reader by exiting with an error message. readerError :: String -> ReadM a data CReader a CReader :: Completer -> ReadM a -> CReader a [crCompleter] :: CReader a -> Completer [crReader] :: CReader a -> ReadM a -- | A Parser a is an option parser returning a value of type -- a. data Parser a NilP :: Maybe a -> Parser a OptP :: Option a -> Parser a MultP :: Parser (x -> a) -> Parser x -> Parser a AltP :: Parser a -> Parser a -> Parser a BindP :: Parser x -> (x -> Parser a) -> Parser a newtype ParserM r ParserM :: (forall x. (r -> Parser x) -> Parser x) -> ParserM r [runParserM] :: ParserM r -> forall x. (r -> Parser x) -> Parser x -- | A shell complete function. newtype Completer Completer :: (String -> IO [String]) -> Completer [runCompleter] :: Completer -> String -> IO [String] -- | Smart constructor for a Completer mkCompleter :: (String -> IO [String]) -> Completer newtype CompletionResult CompletionResult :: (String -> IO String) -> CompletionResult [execCompletion] :: CompletionResult -> String -> IO String newtype ParserFailure h ParserFailure :: (String -> (h, ExitCode, Int)) -> ParserFailure h [execFailure] :: ParserFailure h -> String -> (h, ExitCode, Int) -- | Result of execParserPure. data ParserResult a Success :: a -> ParserResult a Failure :: ParserFailure ParserHelp -> ParserResult a CompletionInvoked :: CompletionResult -> ParserResult a overFailure :: (ParserHelp -> ParserHelp) -> ParserResult a -> ParserResult a type Args = [String] -- | Policy for how to handle options within the parse data ArgPolicy -- | The default policy, options and arguments can be interspersed. A `--` -- option can be passed to ensure all following commands are treated as -- arguments. Intersperse :: ArgPolicy -- | Options must all come before arguments, once a single positional -- argument or subcommand is parsed, all remaining arguments are treated -- as positionals. A `--` option can be passed if the first positional -- one needs starts with -. NoIntersperse :: ArgPolicy -- | No options are parsed at all, all arguments are treated as -- positionals. Is the policy used after `--` is encountered. AllPositionals :: ArgPolicy -- | Options and arguments can be interspersed, but if a given option is -- not found, it is treated as a positional argument. This is sometimes -- useful if one is passing through most options to another tool, but are -- supplying just a few of their own options. ForwardOptions :: ArgPolicy newtype ArgumentReachability ArgumentReachability :: Bool -> ArgumentReachability -- | If the result is a positional, if it can't be accessed in the current -- parser position ( first arg ) [argumentIsUnreachable] :: ArgumentReachability -> Bool -- | This type encapsulates whether an AltNode of an OptTree -- should be displayed with brackets around it. data AltNodeType MarkDefault :: AltNodeType NoDefault :: AltNodeType data OptTree a Leaf :: a -> OptTree a MultNode :: [OptTree a] -> OptTree a AltNode :: AltNodeType -> [OptTree a] -> OptTree a BindNode :: OptTree a -> OptTree a data ParserHelp ParserHelp :: Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> ParserHelp [helpError] :: ParserHelp -> Chunk Doc [helpSuggestions] :: ParserHelp -> Chunk Doc [helpHeader] :: ParserHelp -> Chunk Doc [helpUsage] :: ParserHelp -> Chunk Doc [helpDescription] :: ParserHelp -> Chunk Doc [helpBody] :: ParserHelp -> Chunk Doc [helpGlobals] :: ParserHelp -> Chunk Doc [helpFooter] :: ParserHelp -> Chunk Doc data SomeParser SomeParser :: Parser a -> SomeParser -- | Subparser context, containing the name of the subparser and -- its parser info. Used by parserFailure to display relevant usage -- information when parsing inside a subparser fails. data Context Context :: String -> ParserInfo a -> Context data IsCmdStart CmdStart :: IsCmdStart CmdCont :: IsCmdStart fromM :: ParserM a -> Parser a oneM :: Parser a -> ParserM a manyM :: Parser a -> ParserM [a] someM :: Parser a -> ParserM [a] filterOptional :: OptTree a -> OptTree a optVisibility :: Option a -> OptVisibility optMetaVar :: Option a -> String optHelp :: Option a -> Chunk Doc optShowDefault :: Option a -> Maybe String optDescMod :: Option a -> Maybe (Doc -> Doc) instance GHC.Show.Show Options.Applicative.Types.IsCmdStart instance GHC.Show.Show Options.Applicative.Types.Backtracking instance GHC.Classes.Eq Options.Applicative.Types.Backtracking instance GHC.Show.Show Options.Applicative.Types.ParserPrefs instance GHC.Classes.Eq Options.Applicative.Types.ParserPrefs instance GHC.Show.Show Options.Applicative.Types.OptName instance GHC.Classes.Ord Options.Applicative.Types.OptName instance GHC.Classes.Eq Options.Applicative.Types.OptName instance GHC.Show.Show Options.Applicative.Types.OptVisibility instance GHC.Classes.Ord Options.Applicative.Types.OptVisibility instance GHC.Classes.Eq Options.Applicative.Types.OptVisibility instance GHC.Show.Show a => GHC.Show.Show (Options.Applicative.Types.ParserResult a) instance GHC.Show.Show Options.Applicative.Types.ArgPolicy instance GHC.Classes.Ord Options.Applicative.Types.ArgPolicy instance GHC.Classes.Eq Options.Applicative.Types.ArgPolicy instance GHC.Show.Show Options.Applicative.Types.ArgumentReachability instance GHC.Classes.Eq Options.Applicative.Types.ArgumentReachability instance GHC.Classes.Eq Options.Applicative.Types.AltNodeType instance GHC.Show.Show Options.Applicative.Types.AltNodeType instance GHC.Show.Show a => GHC.Show.Show (Options.Applicative.Types.OptTree a) instance GHC.Base.Monad Options.Applicative.Types.ParserM instance GHC.Base.Functor Options.Applicative.Types.ParserM instance GHC.Base.Applicative Options.Applicative.Types.ParserM instance GHC.Base.Monoid Options.Applicative.Types.ParseError instance GHC.Base.Semigroup Options.Applicative.Types.ParseError instance GHC.Base.Functor Options.Applicative.Types.ParserInfo instance GHC.Show.Show (Options.Applicative.Types.Option a) instance GHC.Base.Functor Options.Applicative.Types.Option instance GHC.Base.Functor Options.Applicative.Types.ReadM instance GHC.Base.Applicative Options.Applicative.Types.ReadM instance GHC.Base.Alternative Options.Applicative.Types.ReadM instance GHC.Base.Monad Options.Applicative.Types.ReadM instance Control.Monad.Fail.MonadFail Options.Applicative.Types.ReadM instance GHC.Base.MonadPlus Options.Applicative.Types.ReadM instance GHC.Base.Functor Options.Applicative.Types.CReader instance GHC.Base.Functor Options.Applicative.Types.OptReader instance GHC.Base.Functor Options.Applicative.Types.Parser instance GHC.Base.Applicative Options.Applicative.Types.Parser instance GHC.Base.Alternative Options.Applicative.Types.Parser instance GHC.Base.Functor Options.Applicative.Types.ParserResult instance GHC.Base.Applicative Options.Applicative.Types.ParserResult instance GHC.Base.Monad Options.Applicative.Types.ParserResult instance GHC.Show.Show h => GHC.Show.Show (Options.Applicative.Types.ParserFailure h) instance GHC.Base.Functor Options.Applicative.Types.ParserFailure instance GHC.Show.Show Options.Applicative.Types.CompletionResult instance GHC.Base.Semigroup Options.Applicative.Types.Completer instance GHC.Base.Monoid Options.Applicative.Types.Completer instance GHC.Show.Show Options.Applicative.Types.OptProperties module Options.Applicative.NonEmpty -- | Sequences an action one or more times. -- -- Functionally identical to some1, but is preferred as it gives a -- nicer help text. some1 :: Parser a -> Parser (NonEmpty a) module Options.Applicative.Internal data P a class (Alternative m, MonadPlus m) => MonadP m enterContext :: MonadP m => String -> ParserInfo a -> m () exitContext :: MonadP m => m () getPrefs :: MonadP m => m ParserPrefs missingArgP :: MonadP m => ParseError -> Completer -> m a errorP :: MonadP m => ParseError -> m a exitP :: MonadP m => IsCmdStart -> ArgPolicy -> Parser b -> Maybe a -> m a data ParseError ErrorMsg :: String -> ParseError InfoMsg :: String -> ParseError ShowHelpText :: Maybe String -> ParseError UnknownError :: ParseError MissingError :: IsCmdStart -> SomeParser -> ParseError ExpectsArgError :: String -> ParseError UnexpectedError :: String -> SomeParser -> ParseError uncons :: [a] -> Maybe (a, [a]) hoistMaybe :: MonadPlus m => Maybe a -> m a hoistEither :: MonadP m => Either ParseError a -> m a runReadM :: MonadP m => ReadM a -> String -> m a withReadM :: (String -> String) -> ReadM a -> ReadM a runP :: P a -> ParserPrefs -> (Either ParseError a, [Context]) data Completion a runCompletion :: Completion r -> ParserPrefs -> Maybe (Either (SomeParser, ArgPolicy) Completer) contextNames :: [Context] -> [String] data ListT m a takeListT :: Monad m => Int -> ListT m a -> ListT m a runListT :: Monad m => ListT m a -> m [a] data NondetT m a cut :: Monad m => NondetT m () () :: Monad m => NondetT m a -> NondetT m a -> NondetT m a disamb :: Monad m => Bool -> NondetT m a -> m (Maybe a) instance GHC.Base.Monad m => GHC.Base.Functor (Options.Applicative.Internal.NondetT m) instance GHC.Base.Monad m => GHC.Base.Applicative (Options.Applicative.Internal.NondetT m) instance GHC.Base.Monad m => GHC.Base.Monad (Options.Applicative.Internal.NondetT m) instance GHC.Base.Monad m => GHC.Base.MonadPlus (Options.Applicative.Internal.NondetT m) instance GHC.Base.Monad m => GHC.Base.Alternative (Options.Applicative.Internal.NondetT m) instance Control.Monad.Trans.Class.MonadTrans Options.Applicative.Internal.NondetT instance GHC.Base.Monad m => GHC.Base.Functor (Options.Applicative.Internal.ListT m) instance GHC.Base.Monad m => GHC.Base.Applicative (Options.Applicative.Internal.ListT m) instance GHC.Base.Monad m => GHC.Base.Monad (Options.Applicative.Internal.ListT m) instance GHC.Base.Monad m => GHC.Base.Alternative (Options.Applicative.Internal.ListT m) instance Control.Monad.Trans.Class.MonadTrans Options.Applicative.Internal.ListT instance GHC.Base.Monad m => GHC.Base.MonadPlus (Options.Applicative.Internal.ListT m) instance GHC.Base.Functor Options.Applicative.Internal.Completion instance GHC.Base.Applicative Options.Applicative.Internal.Completion instance GHC.Base.Alternative Options.Applicative.Internal.Completion instance GHC.Base.Monad Options.Applicative.Internal.Completion instance GHC.Base.MonadPlus Options.Applicative.Internal.Completion instance Options.Applicative.Internal.MonadP Options.Applicative.Internal.Completion instance GHC.Base.Functor Options.Applicative.Internal.ComplResult instance GHC.Base.Applicative Options.Applicative.Internal.ComplResult instance GHC.Base.Monad Options.Applicative.Internal.ComplResult instance GHC.Base.Functor Options.Applicative.Internal.P instance GHC.Base.Applicative Options.Applicative.Internal.P instance GHC.Base.Alternative Options.Applicative.Internal.P instance GHC.Base.Monad Options.Applicative.Internal.P instance GHC.Base.MonadPlus Options.Applicative.Internal.P instance Options.Applicative.Internal.MonadP Options.Applicative.Internal.P module Options.Applicative.Common -- | A Parser a is an option parser returning a value of type -- a. data Parser a -- | Create a parser composed of a single option. liftOpt :: Option a -> Parser a showOption :: OptName -> String -- | A full description for a runnable Parser for a program. data ParserInfo a ParserInfo :: Parser a -> Bool -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Int -> ArgPolicy -> ParserInfo a -- | the option parser for the program [infoParser] :: ParserInfo a -> Parser a -- | whether the help text should contain full documentation [infoFullDesc] :: ParserInfo a -> Bool -- | brief parser description [infoProgDesc] :: ParserInfo a -> Chunk Doc -- | header of the full parser description [infoHeader] :: ParserInfo a -> Chunk Doc -- | footer of the full parser description [infoFooter] :: ParserInfo a -> Chunk Doc -- | exit code for a parser failure [infoFailureCode] :: ParserInfo a -> Int -- | allow regular options and flags to occur after arguments (default: -- InterspersePolicy) [infoPolicy] :: ParserInfo a -> ArgPolicy -- | Global preferences for a top-level Parser. data ParserPrefs ParserPrefs :: String -> Bool -> Bool -> Bool -> Backtracking -> Int -> Bool -> Bool -> Int -> ParserPrefs -- | metavar suffix for multiple options [prefMultiSuffix] :: ParserPrefs -> String -- | automatically disambiguate abbreviations (default: False) [prefDisambiguate] :: ParserPrefs -> Bool -- | always show help text on parse errors (default: False) [prefShowHelpOnError] :: ParserPrefs -> Bool -- | show the help text for a command or subcommand if it fails with no -- input (default: False) [prefShowHelpOnEmpty] :: ParserPrefs -> Bool -- | backtrack to parent parser when a subcommand fails (default: -- Backtrack) [prefBacktrack] :: ParserPrefs -> Backtracking -- | number of columns in the terminal, used to format the help page -- (default: 80) [prefColumns] :: ParserPrefs -> Int -- | when displaying long names in usage and help, use an '=' sign for long -- names, rather than a single space (default: False) [prefHelpLongEquals] :: ParserPrefs -> Bool -- | when displaying subparsers' usage help, show parent options under a -- "global options" section (default: False) [prefHelpShowGlobal] :: ParserPrefs -> Bool -- | Indentation width for tables [prefTabulateFill] :: ParserPrefs -> Int runParserInfo :: MonadP m => ParserInfo a -> Args -> m a runParserFully :: MonadP m => ArgPolicy -> Parser a -> Args -> m a runParserStep :: MonadP m => ArgPolicy -> Parser a -> String -> Args -> m (Maybe (Parser a), Args) -- | Apply a Parser to a command line, and return a result and -- leftover arguments. This function returns an error if any parsing -- error occurs, or if any options are missing and don't have a default -- value. runParser :: MonadP m => ArgPolicy -> IsCmdStart -> Parser a -> Args -> m (a, Args) -- | The default value of a Parser. This function returns an error -- if any of the options don't have a default value. evalParser :: Parser a -> Maybe a -- | Map a polymorphic function over all the options of a parser, and -- collect the results in a list. mapParser :: (forall x. ArgumentReachability -> Option x -> b) -> Parser a -> [b] -- | Like mapParser, but collect the results in a tree structure. treeMapParser :: (forall x. ArgumentReachability -> Option x -> b) -> Parser a -> OptTree b optionNames :: OptReader a -> [OptName] module Options.Applicative.Help.Core -- | Generate descriptions for commands. cmdDesc :: ParserPrefs -> Parser a -> [(Maybe String, Chunk Doc)] -- | Generate a brief help text for a parser. briefDesc :: ParserPrefs -> Parser a -> Chunk Doc -- | Generate a brief help text for a parser, only including mandatory -- options and arguments. missingDesc :: ParserPrefs -> Parser a -> Chunk Doc -- | Generate a full help text for a parser fullDesc :: ParserPrefs -> Parser a -> Chunk Doc -- | Generate a help text for the parser, showing only what is relevant in -- the "Global options: section" globalDesc :: ParserPrefs -> Parser a -> Chunk Doc data ParserHelp ParserHelp :: Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> ParserHelp [helpError] :: ParserHelp -> Chunk Doc [helpSuggestions] :: ParserHelp -> Chunk Doc [helpHeader] :: ParserHelp -> Chunk Doc [helpUsage] :: ParserHelp -> Chunk Doc [helpDescription] :: ParserHelp -> Chunk Doc [helpBody] :: ParserHelp -> Chunk Doc [helpGlobals] :: ParserHelp -> Chunk Doc [helpFooter] :: ParserHelp -> Chunk Doc errorHelp :: Chunk Doc -> ParserHelp headerHelp :: Chunk Doc -> ParserHelp suggestionsHelp :: Chunk Doc -> ParserHelp usageHelp :: Chunk Doc -> ParserHelp descriptionHelp :: Chunk Doc -> ParserHelp bodyHelp :: Chunk Doc -> ParserHelp footerHelp :: Chunk Doc -> ParserHelp globalsHelp :: Chunk Doc -> ParserHelp -- | Generate the help text for a program. parserHelp :: ParserPrefs -> Parser a -> ParserHelp -- | Generate option summary. parserUsage :: ParserPrefs -> Parser a -> String -> Doc parserGlobals :: ParserPrefs -> Parser a -> ParserHelp instance GHC.Show.Show Options.Applicative.Help.Core.Parenthetic instance GHC.Classes.Ord Options.Applicative.Help.Core.Parenthetic instance GHC.Classes.Eq Options.Applicative.Help.Core.Parenthetic module Options.Applicative.Help module Options.Applicative.Builder.Internal -- | An option modifier. -- -- Option modifiers are values that represent a modification of the -- properties of an option. -- -- The type parameter a is the return type of the option, while -- f is a record containing its properties (e.g. -- OptionFields for regular options, FlagFields for flags, -- etc...). -- -- An option modifier consists of 3 elements: -- -- -- -- Modifiers are instances of Monoid, and can be composed as such. -- -- One rarely needs to deal with modifiers directly, as most of the times -- it is sufficient to pass them to builders (such as strOption -- or flag) to create options (see Builder). data Mod f a Mod :: (f a -> f a) -> DefaultProp a -> (OptProperties -> OptProperties) -> Mod f a class HasName f name :: HasName f => OptName -> f a -> f a class HasCompleter f modCompleter :: HasCompleter f => (Completer -> Completer) -> f a -> f a class HasValue f hasValueDummy :: HasValue f => f a -> () class HasMetavar f hasMetavarDummy :: HasMetavar f => f a -> () data OptionFields a OptionFields :: [OptName] -> Completer -> (String -> ParseError) -> OptionFields a [optNames] :: OptionFields a -> [OptName] [optCompleter] :: OptionFields a -> Completer [optNoArgError] :: OptionFields a -> String -> ParseError data FlagFields a FlagFields :: [OptName] -> a -> FlagFields a [flagNames] :: FlagFields a -> [OptName] [flagActive] :: FlagFields a -> a data CommandFields a CommandFields :: [(String, ParserInfo a)] -> Maybe String -> CommandFields a [cmdCommands] :: CommandFields a -> [(String, ParserInfo a)] [cmdGroup] :: CommandFields a -> Maybe String data ArgumentFields a ArgumentFields :: Completer -> ArgumentFields a [argCompleter] :: ArgumentFields a -> Completer data DefaultProp a DefaultProp :: Maybe a -> Maybe (a -> String) -> DefaultProp a optionMod :: (OptProperties -> OptProperties) -> Mod f a fieldMod :: (f a -> f a) -> Mod f a -- | Base default properties. baseProps :: OptProperties mkCommand :: Mod CommandFields a -> (Maybe String, [String], String -> Maybe (ParserInfo a)) mkParser :: DefaultProp a -> (OptProperties -> OptProperties) -> OptReader a -> Parser a mkOption :: DefaultProp a -> (OptProperties -> OptProperties) -> OptReader a -> Option a mkProps :: DefaultProp a -> (OptProperties -> OptProperties) -> OptProperties -- | Hide this option completely from the help text -- -- Use hidden if the option should remain visible in the full -- description. internal :: Mod f a -- | Suppress this option from appearing in global options noGlobal :: Mod f a instance GHC.Base.Monoid (Options.Applicative.Builder.Internal.Mod f a) instance GHC.Base.Semigroup (Options.Applicative.Builder.Internal.Mod f a) instance GHC.Base.Monoid (Options.Applicative.Builder.Internal.DefaultProp a) instance GHC.Base.Semigroup (Options.Applicative.Builder.Internal.DefaultProp a) instance Options.Applicative.Builder.Internal.HasMetavar Options.Applicative.Builder.Internal.OptionFields instance Options.Applicative.Builder.Internal.HasMetavar Options.Applicative.Builder.Internal.ArgumentFields instance Options.Applicative.Builder.Internal.HasMetavar Options.Applicative.Builder.Internal.CommandFields instance Options.Applicative.Builder.Internal.HasValue Options.Applicative.Builder.Internal.OptionFields instance Options.Applicative.Builder.Internal.HasValue Options.Applicative.Builder.Internal.ArgumentFields instance Options.Applicative.Builder.Internal.HasCompleter Options.Applicative.Builder.Internal.OptionFields instance Options.Applicative.Builder.Internal.HasCompleter Options.Applicative.Builder.Internal.ArgumentFields instance Options.Applicative.Builder.Internal.HasName Options.Applicative.Builder.Internal.OptionFields instance Options.Applicative.Builder.Internal.HasName Options.Applicative.Builder.Internal.FlagFields module Options.Applicative.Builder.Completer -- | A shell complete function. data Completer -- | Smart constructor for a Completer mkCompleter :: (String -> IO [String]) -> Completer -- | Create a Completer from an IO action listIOCompleter :: IO [String] -> Completer -- | Create a Completer from a constant list of strings. listCompleter :: [String] -> Completer -- | Run a compgen completion action. -- -- Common actions include file and directory. See -- http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#Programmable-Completion-Builtins -- for a complete list. bashCompleter :: String -> Completer -- | Strongly quote the string we pass to compgen. -- -- We need to do this so bash doesn't expand out any ~ or other chars we -- want to complete on, or emit an end of line error when seeking the -- close to the quote. requote :: String -> String module Options.Applicative.Builder -- | Builder for a command parser. The command modifier can be used -- to specify individual commands. -- -- By default, sub-parsers allow backtracking to their parent's options -- when they are completed. To allow full mixing of parent and sub-parser -- options, turn on subparserInline; otherwise, to disable -- backtracking completely, use noBacktrack. subparser :: Mod CommandFields a -> Parser a -- | Builder for a String argument. strArgument :: IsString s => Mod ArgumentFields s -> Parser s -- | Builder for an argument parser. argument :: ReadM a -> Mod ArgumentFields a -> Parser a -- | Builder for a flag parser. -- -- A flag that switches from a "default value" to an "active value" when -- encountered. For a simple boolean value, use switch instead. -- -- Note: Because this parser will never fail, it can not be used -- with combinators such as some or many, as these -- combinators continue until a failure occurs. See flag'. flag :: a -> a -> Mod FlagFields a -> Parser a -- | Builder for a flag parser without a default value. -- -- Same as flag, but with no default value. In particular, this -- flag will never parse successfully by itself. -- -- It still makes sense to use it as part of a composite parser. For -- example -- --
--   length <$> many (flag' () (short 't'))
--   
-- -- is a parser that counts the number of "-t" arguments on the command -- line, alternatively -- --
--   flag' True (long "on") <|> flag' False (long "off")
--   
-- -- will require the user to enter '--on' or '--off' on the command line. flag' :: a -> Mod FlagFields a -> Parser a -- | Builder for a boolean flag. -- -- Note: Because this parser will never fail, it can not be used -- with combinators such as some or many, as these -- combinators continue until a failure occurs. See flag'. -- --
--   switch = flag False True
--   
switch :: Mod FlagFields Bool -> Parser Bool -- | An option that always fails. -- -- When this option is encountered, the option parser immediately aborts -- with the given parse error. If you simply want to output a message, -- use infoOption instead. abortOption :: ParseError -> Mod OptionFields (a -> a) -> Parser (a -> a) -- | An option that always fails and displays a message. infoOption :: String -> Mod OptionFields (a -> a) -> Parser (a -> a) -- | Builder for an option taking a String argument. strOption :: IsString s => Mod OptionFields s -> Parser s -- | Builder for an option using the given reader. -- -- This is a regular option, and should always have either a -- long or short name specified in the modifiers (or -- both). -- --
--   nameParser = option str ( long "name" <> short 'n' )
--   
option :: ReadM a -> Mod OptionFields a -> Parser a -- | Specify a short name for an option. short :: HasName f => Char -> Mod f a -- | Specify a long name for an option. long :: HasName f => String -> Mod f a -- | Specify the help text for an option. help :: String -> Mod f a -- | Specify the help text for an option as a Doc value. helpDoc :: Maybe Doc -> Mod f a -- | Specify a default value for an option. -- -- Note: Because this modifier means the parser will never fail, -- do not use it with combinators such as some or many, as -- these combinators continue until a failure occurs. Careless use will -- thus result in a hang. -- -- To display the default value, combine with showDefault or -- showDefaultWith. value :: HasValue f => a -> Mod f a -- | Specify a function to show the default value for an option. showDefaultWith :: (a -> String) -> Mod f a -- | Show the default value for this option using its Show instance. showDefault :: Show a => Mod f a -- | Specify a metavariable for the argument. -- -- Metavariables have no effect on the actual parser, and only serve to -- specify the symbolic name for an argument to be displayed in the help -- text. metavar :: HasMetavar f => String -> Mod f a -- | Specify the error to display when no argument is provided to this -- option. noArgError :: ParseError -> Mod OptionFields a data ParseError ErrorMsg :: String -> ParseError InfoMsg :: String -> ParseError ShowHelpText :: Maybe String -> ParseError UnknownError :: ParseError MissingError :: IsCmdStart -> SomeParser -> ParseError ExpectsArgError :: String -> ParseError UnexpectedError :: String -> SomeParser -> ParseError -- | Hide this option from the brief description. -- -- Use internal to hide the option from the help text too. hidden :: Mod f a -- | Hide this option completely from the help text -- -- Use hidden if the option should remain visible in the full -- description. internal :: Mod f a -- | Apply a function to the option description in the usage text. -- --
--   import Options.Applicative.Help
--   flag' () (short 't' <> style bold)
--   
-- -- NOTE: This builder is more flexible than its name and example -- allude. One of the motivating examples for its addition was to use -- const to completely replace the usage text of an option. style :: (Doc -> Doc) -> Mod f a -- | Add a command to a subparser option. -- -- Suggested usage for multiple commands is to add them to a single -- subparser. e.g. -- --
--   sample :: Parser Sample
--   sample = subparser
--          ( command "hello"
--            (info hello (progDesc "Print greeting"))
--         <> command "goodbye"
--            (info goodbye (progDesc "Say goodbye"))
--          )
--   
command :: String -> ParserInfo a -> Mod CommandFields a -- | Add a description to a group of commands. -- -- Advanced feature for separating logical groups of commands on the -- parse line. -- -- If using the same metavar for each group of commands, it may -- yield a more attractive usage text combined with hidden for -- some groups. commandGroup :: String -> Mod CommandFields a -- | Add a list of possible completion values. completeWith :: HasCompleter f => [String] -> Mod f a -- | Add a bash completion action. Common actions include file and -- directory. See -- http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#Programmable-Completion-Builtins -- for a complete list. action :: HasCompleter f => String -> Mod f a -- | Add a completer to an argument. -- -- A completer is a function String -> IO String which, given a -- partial argument, returns all possible completions for that argument. completer :: HasCompleter f => Completer -> Mod f a -- | Trivial option modifier. idm :: Monoid m => m -- | An associative operation -- -- NOTE: This method is redundant and has the default -- implementation mappend = (<>) since -- base-4.11.0.0. Should it be implemented manually, since -- mappend is a synonym for (<>), it is expected that -- the two functions are defined the same way. In a future GHC release -- mappend will be removed from Monoid. mappend :: Monoid a => a -> a -> a -- | Option reader based on the Read type class. auto :: Read a => ReadM a -- | String Option reader. -- -- Polymorphic over the IsString type class since 0.14. str :: IsString s => ReadM s -- | Convert a function producing a Maybe into a reader. maybeReader :: (String -> Maybe a) -> ReadM a -- | Convert a function producing an Either into a reader. -- -- As an example, one can create a ReadM from an attoparsec Parser easily -- with -- --
--   import qualified Data.Attoparsec.Text as A
--   import qualified Data.Text as T
--   attoparsecReader :: A.Parser a -> ReadM a
--   attoparsecReader p = eitherReader (A.parseOnly p . T.pack)
--   
eitherReader :: (String -> Either String a) -> ReadM a -- | Null Option reader. All arguments will fail validation. disabled :: ReadM a -- | Abort option reader by exiting with a ParseError. readerAbort :: ParseError -> ReadM a -- | Abort option reader by exiting with an error message. readerError :: String -> ReadM a -- | Modifier for ParserInfo. data InfoMod a -- | Show a full description in the help text of this parser (default). fullDesc :: InfoMod a -- | Only show a brief description in the help text of this parser. briefDesc :: InfoMod a -- | Specify a header for this parser. header :: String -> InfoMod a -- | Specify a header for this parser as a Doc value. headerDoc :: Maybe Doc -> InfoMod a -- | Specify a footer for this parser. footer :: String -> InfoMod a -- | Specify a footer for this parser as a Doc value. footerDoc :: Maybe Doc -> InfoMod a -- | Specify a short program description. progDesc :: String -> InfoMod a -- | Specify a short program description as a Doc value. progDescDoc :: Maybe Doc -> InfoMod a -- | Specify an exit code if a parse error occurs. failureCode :: Int -> InfoMod a -- | Disable parsing of regular options after arguments. After a positional -- argument is parsed, all remaining options and arguments will be -- treated as a positional arguments. Not recommended in general as users -- often expect to be able to freely intersperse regular options and -- flags within command line options. noIntersperse :: InfoMod a -- | Intersperse matched options and arguments normally, but allow -- unmatched options to be treated as positional arguments. This is -- sometimes useful if one is wrapping a third party cli tool and needs -- to pass options through, while also providing a handful of their own -- options. Not recommended in general as typos by the user may not yield -- a parse error and cause confusion. forwardOptions :: InfoMod a -- | Disable parsing of regular options completely. All options and -- arguments will be treated as a positional arguments. Obviously not -- recommended in general as options will be unreachable. This is the -- same behaviour one sees after the "--" pseudo-argument. allPositional :: InfoMod a -- | Create a ParserInfo given a Parser and a modifier. info :: Parser a -> InfoMod a -> ParserInfo a data PrefsMod -- | Include a suffix to attach to the metavar when multiple values can be -- entered. multiSuffix :: String -> PrefsMod -- | Turn on disambiguation. -- -- See -- https://github.com/pcapriotti/optparse-applicative#disambiguation disambiguate :: PrefsMod -- | Show full help text on any error. showHelpOnError :: PrefsMod -- | Show the help text if the user enters only the program name or -- subcommand. -- -- This will suppress a "Missing:" error and show the full usage instead -- if a user just types the name of the program. showHelpOnEmpty :: PrefsMod -- | Turn off backtracking after subcommand is parsed. noBacktrack :: PrefsMod -- | Allow full mixing of subcommand and parent arguments by inlining -- selected subparsers into the parent parser. -- -- NOTE: When this option is used, preferences for the subparser -- which effect the parser behaviour (such as noIntersperse) are ignored. subparserInline :: PrefsMod -- | Set the maximum width of the generated help text. columns :: Int -> PrefsMod -- | Show equals sign, rather than space, in usage and help text for -- options with long names. helpLongEquals :: PrefsMod -- | Show global help information in subparser usage. helpShowGlobals :: PrefsMod -- | Set fill width in help text presentation. helpIndent :: Int -> PrefsMod -- | Create a ParserPrefs given a modifier prefs :: PrefsMod -> ParserPrefs -- | Default preferences. defaultPrefs :: ParserPrefs -- | An option modifier. -- -- Option modifiers are values that represent a modification of the -- properties of an option. -- -- The type parameter a is the return type of the option, while -- f is a record containing its properties (e.g. -- OptionFields for regular options, FlagFields for flags, -- etc...). -- -- An option modifier consists of 3 elements: -- -- -- -- Modifiers are instances of Monoid, and can be composed as such. -- -- One rarely needs to deal with modifiers directly, as most of the times -- it is sufficient to pass them to builders (such as strOption -- or flag) to create options (see Builder). data Mod f a -- | A newtype over 'ReaderT String Except', used by option readers. data ReadM a data OptionFields a data FlagFields a data ArgumentFields a data CommandFields a class HasName f class HasCompleter f class HasValue f class HasMetavar f instance GHC.Base.Monoid Options.Applicative.Builder.PrefsMod instance GHC.Base.Semigroup Options.Applicative.Builder.PrefsMod instance GHC.Base.Monoid (Options.Applicative.Builder.InfoMod a) instance GHC.Base.Semigroup (Options.Applicative.Builder.InfoMod a) -- | You don't need to import this module to enable bash completion. -- -- See the wiki for more information on bash completion. module Options.Applicative.BashCompletion bashCompletionParser :: ParserInfo a -> ParserPrefs -> Parser CompletionResult -- | Generated bash shell completion script bashCompletionScript :: String -> String -> String -- | Generated fish shell completion script fishCompletionScript :: String -> String -> String -- | Generated zsh shell completion script zshCompletionScript :: String -> String -> String instance GHC.Show.Show Options.Applicative.BashCompletion.Richness instance GHC.Classes.Ord Options.Applicative.BashCompletion.Richness instance GHC.Classes.Eq Options.Applicative.BashCompletion.Richness module Options.Applicative.Extra -- | A hidden "helper" option which always fails. -- -- A common usage pattern is to apply this applicatively when creating a -- ParserInfo -- --
--   opts :: ParserInfo Sample
--   opts = info (sample <**> helper) mempty
--   
helper :: Parser (a -> a) -- | Like helper, but with a minimal set of modifiers that can be extended -- as desired. -- --
--   opts :: ParserInfo Sample
--   opts = info (sample <**> helperWith (mconcat [
--            long "help",
--            short 'h',
--            help "Show this help text",
--            hidden
--          ])) mempty
--   
helperWith :: Mod OptionFields (a -> a) -> Parser (a -> a) -- | Builder for a command parser with a "helper" option attached. Used in -- the same way as subparser, but includes a "--help|-h" inside -- the subcommand. hsubparser :: Mod CommandFields a -> Parser a -- | A hidden "--version" option that displays the version. -- --
--   opts :: ParserInfo Sample
--   opts = info (sample <**> simpleVersioner "v1.2.3") mempty
--   
simpleVersioner :: String -> Parser (a -> a) -- | Run a program description. -- -- Parse command line arguments. Display help text and exit if any parse -- error occurs. execParser :: ParserInfo a -> IO a -- | Run a program description with custom preferences. customExecParser :: ParserPrefs -> ParserInfo a -> IO a -- | The most general way to run a program description in pure code. execParserPure :: ParserPrefs -> ParserInfo a -> [String] -> ParserResult a -- | Extract the actual result from a ParserResult value. -- -- This function returns Nothing in case of errors. Possible error -- messages or completion actions are simply discarded. -- -- If you want to display error messages and invoke completion actions -- appropriately, use handleParseResult instead. getParseResult :: ParserResult a -> Maybe a -- | Handle ParserResult. handleParseResult :: ParserResult a -> IO a -- | Generate a ParserFailure from a ParseError in a given -- Context. -- -- This function can be used, for example, to show the help text for a -- parser: -- --
--   handleParseResult . Failure $ parserFailure pprefs pinfo (ShowHelpText Nothing) mempty
--   
parserFailure :: ParserPrefs -> ParserInfo a -> ParseError -> [Context] -> ParserFailure ParserHelp renderFailure :: ParserFailure ParserHelp -> String -> (String, ExitCode) newtype ParserFailure h ParserFailure :: (String -> (h, ExitCode, Int)) -> ParserFailure h [execFailure] :: ParserFailure h -> String -> (h, ExitCode, Int) overFailure :: (ParserHelp -> ParserHelp) -> ParserResult a -> ParserResult a -- | Result of execParserPure. data ParserResult a Success :: a -> ParserResult a Failure :: ParserFailure ParserHelp -> ParserResult a CompletionInvoked :: CompletionResult -> ParserResult a -- | Global preferences for a top-level Parser. data ParserPrefs ParserPrefs :: String -> Bool -> Bool -> Bool -> Backtracking -> Int -> Bool -> Bool -> Int -> ParserPrefs -- | metavar suffix for multiple options [prefMultiSuffix] :: ParserPrefs -> String -- | automatically disambiguate abbreviations (default: False) [prefDisambiguate] :: ParserPrefs -> Bool -- | always show help text on parse errors (default: False) [prefShowHelpOnError] :: ParserPrefs -> Bool -- | show the help text for a command or subcommand if it fails with no -- input (default: False) [prefShowHelpOnEmpty] :: ParserPrefs -> Bool -- | backtrack to parent parser when a subcommand fails (default: -- Backtrack) [prefBacktrack] :: ParserPrefs -> Backtracking -- | number of columns in the terminal, used to format the help page -- (default: 80) [prefColumns] :: ParserPrefs -> Int -- | when displaying long names in usage and help, use an '=' sign for long -- names, rather than a single space (default: False) [prefHelpLongEquals] :: ParserPrefs -> Bool -- | when displaying subparsers' usage help, show parent options under a -- "global options" section (default: False) [prefHelpShowGlobal] :: ParserPrefs -> Bool -- | Indentation width for tables [prefTabulateFill] :: ParserPrefs -> Int newtype CompletionResult CompletionResult :: (String -> IO String) -> CompletionResult [execCompletion] :: CompletionResult -> String -> IO String module Options.Applicative -- | A Parser a is an option parser returning a value of type -- a. data Parser a -- | Builder for a flag parser. -- -- A flag that switches from a "default value" to an "active value" when -- encountered. For a simple boolean value, use switch instead. -- -- Note: Because this parser will never fail, it can not be used -- with combinators such as some or many, as these -- combinators continue until a failure occurs. See flag'. flag :: a -> a -> Mod FlagFields a -> Parser a -- | Builder for a flag parser without a default value. -- -- Same as flag, but with no default value. In particular, this -- flag will never parse successfully by itself. -- -- It still makes sense to use it as part of a composite parser. For -- example -- --
--   length <$> many (flag' () (short 't'))
--   
-- -- is a parser that counts the number of "-t" arguments on the command -- line, alternatively -- --
--   flag' True (long "on") <|> flag' False (long "off")
--   
-- -- will require the user to enter '--on' or '--off' on the command line. flag' :: a -> Mod FlagFields a -> Parser a -- | Builder for a boolean flag. -- -- Note: Because this parser will never fail, it can not be used -- with combinators such as some or many, as these -- combinators continue until a failure occurs. See flag'. -- --
--   switch = flag False True
--   
switch :: Mod FlagFields Bool -> Parser Bool -- | Builder for an option taking a String argument. strOption :: IsString s => Mod OptionFields s -> Parser s -- | Builder for an option using the given reader. -- -- This is a regular option, and should always have either a -- long or short name specified in the modifiers (or -- both). -- --
--   nameParser = option str ( long "name" <> short 'n' )
--   
option :: ReadM a -> Mod OptionFields a -> Parser a -- | Builder for a String argument. strArgument :: IsString s => Mod ArgumentFields s -> Parser s -- | Builder for an argument parser. argument :: ReadM a -> Mod ArgumentFields a -> Parser a -- | Builder for a command parser. The command modifier can be used -- to specify individual commands. -- -- By default, sub-parsers allow backtracking to their parent's options -- when they are completed. To allow full mixing of parent and sub-parser -- options, turn on subparserInline; otherwise, to disable -- backtracking completely, use noBacktrack. subparser :: Mod CommandFields a -> Parser a -- | Builder for a command parser with a "helper" option attached. Used in -- the same way as subparser, but includes a "--help|-h" inside -- the subcommand. hsubparser :: Mod CommandFields a -> Parser a -- | An option that always fails. -- -- When this option is encountered, the option parser immediately aborts -- with the given parse error. If you simply want to output a message, -- use infoOption instead. abortOption :: ParseError -> Mod OptionFields (a -> a) -> Parser (a -> a) -- | An option that always fails and displays a message. infoOption :: String -> Mod OptionFields (a -> a) -> Parser (a -> a) -- | A hidden "helper" option which always fails. -- -- A common usage pattern is to apply this applicatively when creating a -- ParserInfo -- --
--   opts :: ParserInfo Sample
--   opts = info (sample <**> helper) mempty
--   
helper :: Parser (a -> a) -- | A hidden "--version" option that displays the version. -- --
--   opts :: ParserInfo Sample
--   opts = info (sample <**> simpleVersioner "v1.2.3") mempty
--   
simpleVersioner :: String -> Parser (a -> a) -- | An option modifier. -- -- Option modifiers are values that represent a modification of the -- properties of an option. -- -- The type parameter a is the return type of the option, while -- f is a record containing its properties (e.g. -- OptionFields for regular options, FlagFields for flags, -- etc...). -- -- An option modifier consists of 3 elements: -- -- -- -- Modifiers are instances of Monoid, and can be composed as such. -- -- One rarely needs to deal with modifiers directly, as most of the times -- it is sufficient to pass them to builders (such as strOption -- or flag) to create options (see Builder). data Mod f a -- | Specify a short name for an option. short :: HasName f => Char -> Mod f a -- | Specify a long name for an option. long :: HasName f => String -> Mod f a -- | Specify the help text for an option. help :: String -> Mod f a -- | Specify the help text for an option as a Doc value. helpDoc :: Maybe Doc -> Mod f a -- | Specify a default value for an option. -- -- Note: Because this modifier means the parser will never fail, -- do not use it with combinators such as some or many, as -- these combinators continue until a failure occurs. Careless use will -- thus result in a hang. -- -- To display the default value, combine with showDefault or -- showDefaultWith. value :: HasValue f => a -> Mod f a -- | Specify a function to show the default value for an option. showDefaultWith :: (a -> String) -> Mod f a -- | Show the default value for this option using its Show instance. showDefault :: Show a => Mod f a -- | Specify a metavariable for the argument. -- -- Metavariables have no effect on the actual parser, and only serve to -- specify the symbolic name for an argument to be displayed in the help -- text. metavar :: HasMetavar f => String -> Mod f a -- | Specify the error to display when no argument is provided to this -- option. noArgError :: ParseError -> Mod OptionFields a -- | Hide this option from the brief description. -- -- Use internal to hide the option from the help text too. hidden :: Mod f a -- | Hide this option completely from the help text -- -- Use hidden if the option should remain visible in the full -- description. internal :: Mod f a -- | Apply a function to the option description in the usage text. -- --
--   import Options.Applicative.Help
--   flag' () (short 't' <> style bold)
--   
-- -- NOTE: This builder is more flexible than its name and example -- allude. One of the motivating examples for its addition was to use -- const to completely replace the usage text of an option. style :: (Doc -> Doc) -> Mod f a -- | Add a command to a subparser option. -- -- Suggested usage for multiple commands is to add them to a single -- subparser. e.g. -- --
--   sample :: Parser Sample
--   sample = subparser
--          ( command "hello"
--            (info hello (progDesc "Print greeting"))
--         <> command "goodbye"
--            (info goodbye (progDesc "Say goodbye"))
--          )
--   
command :: String -> ParserInfo a -> Mod CommandFields a -- | Add a description to a group of commands. -- -- Advanced feature for separating logical groups of commands on the -- parse line. -- -- If using the same metavar for each group of commands, it may -- yield a more attractive usage text combined with hidden for -- some groups. commandGroup :: String -> Mod CommandFields a -- | Add a list of possible completion values. completeWith :: HasCompleter f => [String] -> Mod f a -- | Add a bash completion action. Common actions include file and -- directory. See -- http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#Programmable-Completion-Builtins -- for a complete list. action :: HasCompleter f => String -> Mod f a -- | Add a completer to an argument. -- -- A completer is a function String -> IO String which, given a -- partial argument, returns all possible completions for that argument. completer :: HasCompleter f => Completer -> Mod f a -- | Trivial option modifier. idm :: Monoid m => m -- | An associative operation -- -- NOTE: This method is redundant and has the default -- implementation mappend = (<>) since -- base-4.11.0.0. Should it be implemented manually, since -- mappend is a synonym for (<>), it is expected that -- the two functions are defined the same way. In a future GHC release -- mappend will be removed from Monoid. mappend :: Monoid a => a -> a -> a data OptionFields a data FlagFields a data ArgumentFields a data CommandFields a class HasName f class HasCompleter f class HasValue f class HasMetavar f -- | A newtype over 'ReaderT String Except', used by option readers. data ReadM a -- | Option reader based on the Read type class. auto :: Read a => ReadM a -- | String Option reader. -- -- Polymorphic over the IsString type class since 0.14. str :: IsString s => ReadM s -- | Convert a function producing a Maybe into a reader. maybeReader :: (String -> Maybe a) -> ReadM a -- | Convert a function producing an Either into a reader. -- -- As an example, one can create a ReadM from an attoparsec Parser easily -- with -- --
--   import qualified Data.Attoparsec.Text as A
--   import qualified Data.Text as T
--   attoparsecReader :: A.Parser a -> ReadM a
--   attoparsecReader p = eitherReader (A.parseOnly p . T.pack)
--   
eitherReader :: (String -> Either String a) -> ReadM a -- | Null Option reader. All arguments will fail validation. disabled :: ReadM a -- | Abort option reader by exiting with a ParseError. readerAbort :: ParseError -> ReadM a -- | Abort option reader by exiting with an error message. readerError :: String -> ReadM a -- | Create a ParserInfo given a Parser and a modifier. info :: Parser a -> InfoMod a -> ParserInfo a -- | A full description for a runnable Parser for a program. data ParserInfo a ParserInfo :: Parser a -> Bool -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Int -> ArgPolicy -> ParserInfo a -- | the option parser for the program [infoParser] :: ParserInfo a -> Parser a -- | whether the help text should contain full documentation [infoFullDesc] :: ParserInfo a -> Bool -- | brief parser description [infoProgDesc] :: ParserInfo a -> Chunk Doc -- | header of the full parser description [infoHeader] :: ParserInfo a -> Chunk Doc -- | footer of the full parser description [infoFooter] :: ParserInfo a -> Chunk Doc -- | exit code for a parser failure [infoFailureCode] :: ParserInfo a -> Int -- | allow regular options and flags to occur after arguments (default: -- InterspersePolicy) [infoPolicy] :: ParserInfo a -> ArgPolicy -- | Modifier for ParserInfo. data InfoMod a -- | Show a full description in the help text of this parser (default). fullDesc :: InfoMod a -- | Only show a brief description in the help text of this parser. briefDesc :: InfoMod a -- | Specify a header for this parser. header :: String -> InfoMod a -- | Specify a header for this parser as a Doc value. headerDoc :: Maybe Doc -> InfoMod a -- | Specify a footer for this parser. footer :: String -> InfoMod a -- | Specify a footer for this parser as a Doc value. footerDoc :: Maybe Doc -> InfoMod a -- | Specify a short program description. progDesc :: String -> InfoMod a -- | Specify a short program description as a Doc value. progDescDoc :: Maybe Doc -> InfoMod a -- | Specify an exit code if a parse error occurs. failureCode :: Int -> InfoMod a -- | Disable parsing of regular options after arguments. After a positional -- argument is parsed, all remaining options and arguments will be -- treated as a positional arguments. Not recommended in general as users -- often expect to be able to freely intersperse regular options and -- flags within command line options. noIntersperse :: InfoMod a -- | Intersperse matched options and arguments normally, but allow -- unmatched options to be treated as positional arguments. This is -- sometimes useful if one is wrapping a third party cli tool and needs -- to pass options through, while also providing a handful of their own -- options. Not recommended in general as typos by the user may not yield -- a parse error and cause confusion. forwardOptions :: InfoMod a -- | Run a program description. -- -- Parse command line arguments. Display help text and exit if any parse -- error occurs. execParser :: ParserInfo a -> IO a -- | Run a program description with custom preferences. customExecParser :: ParserPrefs -> ParserInfo a -> IO a -- | The most general way to run a program description in pure code. execParserPure :: ParserPrefs -> ParserInfo a -> [String] -> ParserResult a -- | Extract the actual result from a ParserResult value. -- -- This function returns Nothing in case of errors. Possible error -- messages or completion actions are simply discarded. -- -- If you want to display error messages and invoke completion actions -- appropriately, use handleParseResult instead. getParseResult :: ParserResult a -> Maybe a -- | Handle ParserResult. handleParseResult :: ParserResult a -> IO a -- | Generate a ParserFailure from a ParseError in a given -- Context. -- -- This function can be used, for example, to show the help text for a -- parser: -- --
--   handleParseResult . Failure $ parserFailure pprefs pinfo (ShowHelpText Nothing) mempty
--   
parserFailure :: ParserPrefs -> ParserInfo a -> ParseError -> [Context] -> ParserFailure ParserHelp renderFailure :: ParserFailure ParserHelp -> String -> (String, ExitCode) overFailure :: (ParserHelp -> ParserHelp) -> ParserResult a -> ParserResult a -- | Create a ParserPrefs given a modifier prefs :: PrefsMod -> ParserPrefs -- | Global preferences for a top-level Parser. data ParserPrefs ParserPrefs :: String -> Bool -> Bool -> Bool -> Backtracking -> Int -> Bool -> Bool -> Int -> ParserPrefs -- | metavar suffix for multiple options [prefMultiSuffix] :: ParserPrefs -> String -- | automatically disambiguate abbreviations (default: False) [prefDisambiguate] :: ParserPrefs -> Bool -- | always show help text on parse errors (default: False) [prefShowHelpOnError] :: ParserPrefs -> Bool -- | show the help text for a command or subcommand if it fails with no -- input (default: False) [prefShowHelpOnEmpty] :: ParserPrefs -> Bool -- | backtrack to parent parser when a subcommand fails (default: -- Backtrack) [prefBacktrack] :: ParserPrefs -> Backtracking -- | number of columns in the terminal, used to format the help page -- (default: 80) [prefColumns] :: ParserPrefs -> Int -- | when displaying long names in usage and help, use an '=' sign for long -- names, rather than a single space (default: False) [prefHelpLongEquals] :: ParserPrefs -> Bool -- | when displaying subparsers' usage help, show parent options under a -- "global options" section (default: False) [prefHelpShowGlobal] :: ParserPrefs -> Bool -- | Indentation width for tables [prefTabulateFill] :: ParserPrefs -> Int data PrefsMod -- | Include a suffix to attach to the metavar when multiple values can be -- entered. multiSuffix :: String -> PrefsMod -- | Turn on disambiguation. -- -- See -- https://github.com/pcapriotti/optparse-applicative#disambiguation disambiguate :: PrefsMod -- | Show full help text on any error. showHelpOnError :: PrefsMod -- | Show the help text if the user enters only the program name or -- subcommand. -- -- This will suppress a "Missing:" error and show the full usage instead -- if a user just types the name of the program. showHelpOnEmpty :: PrefsMod -- | Turn off backtracking after subcommand is parsed. noBacktrack :: PrefsMod -- | Allow full mixing of subcommand and parent arguments by inlining -- selected subparsers into the parent parser. -- -- NOTE: When this option is used, preferences for the subparser -- which effect the parser behaviour (such as noIntersperse) are ignored. subparserInline :: PrefsMod -- | Set the maximum width of the generated help text. columns :: Int -> PrefsMod -- | Show equals sign, rather than space, in usage and help text for -- options with long names. helpLongEquals :: PrefsMod -- | Show global help information in subparser usage. helpShowGlobals :: PrefsMod -- | Set fill width in help text presentation. helpIndent :: Int -> PrefsMod -- | Default preferences. defaultPrefs :: ParserPrefs -- | A shell complete function. data Completer -- | Smart constructor for a Completer mkCompleter :: (String -> IO [String]) -> Completer -- | Create a Completer from an IO action listIOCompleter :: IO [String] -> Completer -- | Create a Completer from a constant list of strings. listCompleter :: [String] -> Completer -- | Run a compgen completion action. -- -- Common actions include file and directory. See -- http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#Programmable-Completion-Builtins -- for a complete list. bashCompleter :: String -> Completer data ParseError ErrorMsg :: String -> ParseError InfoMsg :: String -> ParseError ShowHelpText :: Maybe String -> ParseError UnknownError :: ParseError MissingError :: IsCmdStart -> SomeParser -> ParseError ExpectsArgError :: String -> ParseError UnexpectedError :: String -> SomeParser -> ParseError data ParserHelp ParserHelp :: Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> ParserHelp [helpError] :: ParserHelp -> Chunk Doc [helpSuggestions] :: ParserHelp -> Chunk Doc [helpHeader] :: ParserHelp -> Chunk Doc [helpUsage] :: ParserHelp -> Chunk Doc [helpDescription] :: ParserHelp -> Chunk Doc [helpBody] :: ParserHelp -> Chunk Doc [helpGlobals] :: ParserHelp -> Chunk Doc [helpFooter] :: ParserHelp -> Chunk Doc newtype ParserFailure h ParserFailure :: (String -> (h, ExitCode, Int)) -> ParserFailure h [execFailure] :: ParserFailure h -> String -> (h, ExitCode, Int) -- | Result of execParserPure. data ParserResult a Success :: a -> ParserResult a Failure :: ParserFailure ParserHelp -> ParserResult a CompletionInvoked :: CompletionResult -> ParserResult a newtype CompletionResult CompletionResult :: (String -> IO String) -> CompletionResult [execCompletion] :: CompletionResult -> String -> IO String -- | This module contains an arrow interface for option parsers, which -- allows to define and combine parsers using the arrow notation and -- arrow combinators. -- -- The arrow syntax is particularly useful to create parsers of nested -- structures, or records where the order of fields is different from the -- order in which the parsers should be applied. -- -- For example, an arguments parser often needs to be applied -- last, and that makes it inconvenient to use it for a field which is -- not the last one in a record. -- -- Using the arrow syntax and the functions in this module, one can -- write, e.g.: -- --
--   data Options = Options
--     { optArgs :: [String]
--     , optVerbose :: Bool }
--   
--   opts :: Parser Options
--   opts = runA $ proc () -> do
--     verbose <- asA (switch (short 'v')) -< ()
--     args <- asA (arguments str idm) -< ()
--     returnA -< Options args verbose
--   
-- -- Parser arrows, created out of regular Parser values using the -- asA function, are arrows taking () as argument and -- returning the parsed value. module Options.Applicative.Arrows -- | For any Applicative functor f, A f is the -- Arrow instance associated to f. -- -- The A constructor can be used to convert a value of type f -- (a -> b) into an arrow. newtype A f a b A :: f (a -> b) -> A f a b [unA] :: A f a b -> f (a -> b) -- | Convert a value of type f a into an arrow taking () -- as argument. -- -- Applied to a value of type Parser, it turns it into an arrow -- that can be used inside an arrow command, or passed to arrow -- combinators. asA :: Applicative f => f a -> A f () a -- | Convert an arrow back to an applicative value. -- -- This function can be used to return a result of type Parser -- from an arrow command. runA :: Applicative f => A f () a -> f a -- | The type of arrows associated to the applicative Parser -- functor. type ParserA = A Parser instance GHC.Base.Applicative f => Control.Category.Category (Options.Applicative.Arrows.A f) instance GHC.Base.Applicative f => Control.Arrow.Arrow (Options.Applicative.Arrows.A f)