Copyright | (c) Fumiaki Kinoshita 2018 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <[email protected]> |
Safe Haskell | None |
Language | Haskell2010 |
Data.Extensible.GetOpt
Description
A wrapper for GetOpt
.
Synopsis
- data OptionDescr (h :: k -> Type) (a :: k) = OptionDescr (s -> h a) !s (OptDescr (s -> s))
- type OptDescr' = OptionDescr Identity
- getOptRecord :: forall {v} {k} (h :: v -> Type) (xs :: [Assoc k v]). RecordOf (OptionDescr h) xs -> [String] -> (RecordOf h xs, [String], [String], String -> String)
- withGetOpt :: forall {v} {k} m (h :: v -> Type) (xs :: [Assoc k v]) a. MonadIO m => String -> RecordOf (OptionDescr h) xs -> (RecordOf h xs -> [String] -> m a) -> m a
- optFlag :: [Char] -> [String] -> String -> OptDescr' Bool
- optLastArg :: [Char] -> [String] -> String -> String -> OptDescr' (Maybe String)
- optNoArg :: [Char] -> [String] -> String -> OptDescr' Int
- optReqArg :: [Char] -> [String] -> String -> String -> OptDescr' [String]
- optionNoArg :: forall {k} h (a :: k). (Int -> h a) -> [Char] -> [String] -> String -> OptionDescr h a
- optionReqArg :: forall {k} h (a :: k). ([String] -> h a) -> [Char] -> [String] -> String -> String -> OptionDescr h a
- optionOptArg :: forall {k} h (a :: k). ([Maybe String] -> h a) -> [Char] -> [String] -> String -> String -> OptionDescr h a
Documentation
data OptionDescr (h :: k -> Type) (a :: k) Source #
OptDescr
with a default
Constructors
OptionDescr (s -> h a) !s (OptDescr (s -> s)) |
Instances
Wrapper (OptionDescr h :: k -> Type) Source # | |
Defined in Data.Extensible.GetOpt Methods _Wrapper :: forall f p (v :: k). (Functor f, Profunctor p) => Optic' p f (OptionDescr h v) (Repr (OptionDescr h) v) Source # wrap :: forall (v :: k). Repr (OptionDescr h) v -> OptionDescr h v Source # unwrap :: forall (v :: k). OptionDescr h v -> Repr (OptionDescr h) v Source # | |
Functor h => Functor (OptionDescr h) Source # | |
Defined in Data.Extensible.GetOpt Methods fmap :: (a -> b) -> OptionDescr h a -> OptionDescr h b # (<$) :: a -> OptionDescr h b -> OptionDescr h a # | |
type Repr (OptionDescr h :: k -> Type) (a :: k) Source # | |
Defined in Data.Extensible.GetOpt |
type OptDescr' = OptionDescr Identity Source #
Simple option descriptor
Arguments
:: forall {v} {k} (h :: v -> Type) (xs :: [Assoc k v]). RecordOf (OptionDescr h) xs | a record of option descriptors |
-> [String] | arguments |
-> (RecordOf h xs, [String], [String], String -> String) | (result, remaining non-options, errors, usageInfo) |
Parse option arguments.
Arguments
:: forall {v} {k} m (h :: v -> Type) (xs :: [Assoc k v]) a. MonadIO m | |
=> String | Non-option usage |
-> RecordOf (OptionDescr h) xs | option desciptors |
-> (RecordOf h xs -> [String] -> m a) | the result and non-option arguments |
-> m a |
An all-in-one utility function.
When there's an error, print it along with the usage info to stderr
and terminate with exitFailure
.
Basic descriptors
True when specified
Arguments
:: [Char] | short option |
-> [String] | long option |
-> String | placeholder |
-> String | explanation |
-> OptDescr' (Maybe String) |
Takes the last argument when more than one is specified.
More generic descriptors
Option without an argument; the result is the total count of this option.
Arguments
:: [Char] | short option |
-> [String] | long option |
-> String | placeholder |
-> String | explanation |
-> OptDescr' [String] |
Option with an argument
optionNoArg :: forall {k} h (a :: k). (Int -> h a) -> [Char] -> [String] -> String -> OptionDescr h a Source #
Wrapper-generic version of optNoArg
optionReqArg :: forall {k} h (a :: k). ([String] -> h a) -> [Char] -> [String] -> String -> String -> OptionDescr h a Source #
Wrapper-generic version of optReqArg
optionOptArg :: forall {k} h (a :: k). ([Maybe String] -> h a) -> [Char] -> [String] -> String -> String -> OptionDescr h a Source #
Construct an option with an optional argument