module Test.Hspec.Core.Extension.Option {-# WARNING "This API is experimental." #-} (
  Option
, flag
, argument
, noArgument
, optionalArgument
) where

import           Prelude ()
import           Test.Hspec.Core.Compat

import qualified GetOpt.Declarative as Declarative
import qualified Test.Hspec.Core.Config.Definition as Core

import           Test.Hspec.Core.Extension.Config.Type (Option(..), Config)

flag :: String -> (Bool -> Config -> Config) -> String -> Option
flag :: String -> (Bool -> Config -> Config) -> String -> Option
flag String
name Bool -> Config -> Config
setter = Option Config -> Option
Option (Option Config -> Option)
-> (String -> Option Config) -> String -> Option
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> (Bool -> Config -> Config) -> String -> Option Config
forall config.
String -> (Bool -> config -> config) -> String -> Option config
Core.flag String
name Bool -> Config -> Config
setter

argument :: String -> String -> (String -> Config -> Maybe Config) -> String -> Option
argument :: String
-> String -> (String -> Config -> Maybe Config) -> String -> Option
argument String
name String
argumentName String -> Config -> Maybe Config
setter = Option Config -> Option
Option (Option Config -> Option)
-> (String -> Option Config) -> String -> Option
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> OptionSetter Config -> String -> Option Config
forall config.
String -> OptionSetter config -> String -> Option config
Core.option String
name (String -> (String -> Config -> Maybe Config) -> OptionSetter Config
forall config.
String -> (String -> config -> Maybe config) -> OptionSetter config
Declarative.Arg String
argumentName String -> Config -> Maybe Config
setter)

optionalArgument :: String -> String -> (Maybe String -> Config -> Maybe Config) -> String -> Option
optionalArgument :: String
-> String
-> (Maybe String -> Config -> Maybe Config)
-> String
-> Option
optionalArgument String
name String
argumentName Maybe String -> Config -> Maybe Config
setter = Option Config -> Option
Option (Option Config -> Option)
-> (String -> Option Config) -> String -> Option
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> OptionSetter Config -> String -> Option Config
forall config.
String -> OptionSetter config -> String -> Option config
Core.option String
name (String
-> (Maybe String -> Config -> Maybe Config) -> OptionSetter Config
forall config.
String
-> (Maybe String -> config -> Maybe config) -> OptionSetter config
Declarative.OptArg String
argumentName Maybe String -> Config -> Maybe Config
setter)

noArgument :: String -> (Config -> Config) -> String -> Option
noArgument :: String -> (Config -> Config) -> String -> Option
noArgument String
name Config -> Config
setter String
help = Option Config -> Option
Option (Option Config -> Option) -> Option Config -> Option
forall a b. (a -> b) -> a -> b
$ String
-> Maybe Char
-> OptionSetter Config
-> String
-> Bool
-> Option Config
forall config.
String
-> Maybe Char
-> OptionSetter config
-> String
-> Bool
-> Option config
Declarative.Option String
name Maybe Char
forall a. Maybe a
Nothing ((Config -> Config) -> OptionSetter Config
forall config. (config -> config) -> OptionSetter config
Declarative.NoArg Config -> Config
setter) String
help Bool
False