-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple command line argument parsing -- @package getopt-generics @version 0.4 -- | 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 :: 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. -- -- Implementing custom instances to allow different types is possible. In -- the easiest case you just implement argumentType and -- parseArgument (the minimal complete definition). -- -- (Unfortunately implementing instances for lists or Maybes of -- custom types is not very straightforward.) 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 Typeable FieldState instance Option [Int] instance Option (Maybe Int) instance Option Int instance Option [String] instance Option (Maybe String) instance Option String instance Option Bool