Node.Optlicative
- Package
- purescript-optlicative
- Repository
- Thimoteus/purescript-optlicative
#throw Source
throw :: forall a. OptError -> Optlicative aA combinator that always fails.
#flag Source
flag :: String -> Maybe Char -> Optlicative BooleanCheck whether a boolean value appears as an option. This combinator cannot
fail, as absence of its option is interpreted as false. The first argument
is the expected name, the second is an optional character for single-hyphen
style: For example, boolean "optimize" (Just 'O') will parse both
--optimize and -O.
#optional Source
optional :: forall a. Optlicative a -> Optlicative (Maybe a)Instead of failing, turns an optlicative parser into one that always succeeds
but may do so with Nothing if no such option is found.
This is useful for --help flags in particular: Without this combinator,
it's easy to make an Optlicative that gives an unhelpful MissingOpt
error message when all the user did was try to find help text for a command.
#withDefault Source
withDefault :: forall a. a -> Optlicative a -> Optlicative aInstead of failing, turns an optlicative parser into one that always succeeds but may do so with the given default argument if no such option is found.
#withDefaultM Source
withDefaultM :: forall m. Monoid m => Optlicative m -> Optlicative mLike withDefault but the default value is mempty.
#optForeign Source
optForeign :: String -> Maybe ErrorMsg -> Optlicative ForeignCheck whether something appears as an option, and coerce it to Foreign if
it does. This can be used to parse a JSON argument, for example.
#many Source
many :: forall a. Optlicative a -> Optlicative (List a)Apply an Optlicative parser zero or more times, collecting the
results in a List.
#defaultPreferences Source
defaultPreferences :: Preferences VoidA Preferences that errors on unrecognized options, has no usage text,
and uses an always-failing parser for global options.
#renderErrors Source
renderErrors :: List OptError -> StringA convenience function for nicely printing error messages.
Re-exports from Node.Commando
#Opt Source
data Opt (a :: Type) (row :: Row Type)Constructors
Opt (Optlicative a) (Record row)
Instances
(IsSymbol k, RLCommando tail rowtail a, RLCommando list' row' a, Cons k (Opt a row') rowtail row, Lacks k rowtail, RowToList rowtail tail, RowToList row (Cons k (Opt a row') tail), RowToList row' list') => RLCommando (Cons k (Opt a row') tail) row a
#endOpt Source
endOpt :: forall a. Optlicative a -> Opt a ()Re-exports from Node.Optlicative.Types
#Preferences Source
type Preferences a = { errorOnUnrecognizedOpts :: Boolean, globalOpts :: Optlicative a, usage :: Maybe String }