-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple command line argument parsing -- @package getopt-generics @version 0.5 -- | getopt-generics tries to make it very simple to create -- command line argument parsers. An introductory example can be found in -- the README. module System.Console.GetOpt.Generics -- | Parses command line arguments (gotten from withArgs) and -- returns the parsed value. This function should be enough for simple -- use-cases. -- -- May throw the following exceptions: -- -- getArguments :: (Generic a, HasDatatypeInfo a, All2 Option (Code a)) => IO a -- | Like getArguments but allows you to pass in Modifiers. modifiedGetArguments :: (Generic a, HasDatatypeInfo a, All2 Option (Code a)) => [Modifier] -> IO a -- | Pure variant of getArguments. Also allows to declare -- Modifiers. -- -- Does not throw any exceptions. parseArguments :: (Generic a, HasDatatypeInfo a, All2 Option (Code a)) => String -> [Modifier] -> [String] -> Result a -- | Type to wrap results from the pure parsing functions. data Result a -- | The CLI was used correctly and a value of type a was -- successfully constructed. Success :: a -> Result a -- | The CLI was used incorrectly. The Result contains a list of -- error messages. -- -- It can also happen that the data type you're trying to use isn't -- supported. See the README for details. Errors :: [String] -> Result a -- | The CLI was used with --help. The Result contains the -- help message. OutputAndExit :: String -> Result a -- | Modifiers can be used to customize the command line parser. data Modifier -- | AddShortOption fieldName c adds the Char c as -- a short option for the field addressed by fieldName. AddShortOption :: String -> Char -> Modifier -- | RenameOption fieldName customName renames the option -- generated through the fieldName by customName. RenameOption :: String -> String -> Modifier -- | UseForPositionalArguments fieldName fills the field addressed -- by fieldName with the positional arguments (i.e. arguments -- that don't correspond to a flag). The field has to have type -- [String]. UseForPositionalArguments :: String -> Modifier -- | Derives AddShortOptions for all fields of the datatype that -- start with a unique character. deriveShortOptions :: (HasDatatypeInfo a, SingI (Code a)) => Proxy a -> [Modifier] -- | Type class for all allowed field types. -- -- If you want to use custom field types you should implement an -- instance Option YourCustomType containing implementations of -- argumentType and parseArgument (the minimal complete -- definition). For an example see the README. class Typeable a => Option a where _toOption = ReqArg parseAsFieldState (argumentType (Proxy :: Proxy a)) _emptyOption flagName = Unset ("missing option: --" ++ flagName ++ "=" ++ argumentType (Proxy :: Proxy a)) _accumulate _ x = x argumentType :: Option a => Proxy a -> String parseArgument :: Option a => String -> Maybe a _toOption :: Option a => ArgDescr (FieldState a) _emptyOption :: Option a => String -> FieldState a _accumulate :: Option a => a -> a -> a instance [overlap ok] Typeable FieldState instance [overlap ok] Option Int instance [overlap ok] Option String instance [overlap ok] Option a => Option (Maybe a) instance [overlap ok] Option a => Option [a] instance [overlap ok] Option Bool