skeletest
Safe HaskellNone
LanguageGHC2021

Skeletest.Internal.CLI

Contents

Synopsis

Documentation

data Flag Source #

Register a CLI flag.

Usage:

{- MyFixture.hs -}
import Skeletest

newtype MyFlag = MyFlag String
instance IsFlag MyFlag where
  flagName = "my-flag"
  flagHelp = "The value for MyFixture"
  flagSpec =
    OptionalFlag
      { flagDefault = "foo"
      , flagParse = case
          "illegal" -> Left "invalid flag value"
          s -> Right (MyFlag s)
      }

instance Fixture MyFixture where
  fixtureAction = do
    MyFlag val <- getFlag
    ...

{- Main.hs -}
import MyFixture

cliFlags =
  [ flag @MyFlag
  ]

Constructors

IsFlag a => Flag (Proxy a) 

data FlagSpec a Source #

Constructors

SwitchFlag 

Fields

RequiredFlag 

Fields

OptionalFlag 

Fields

getFlag :: forall a m. (MonadIO m, IsFlag a) => m a Source #

loadCliArgs :: [Flag] -> [Flag] -> IO TestTargets Source #

Parse the CLI arguments using the given user-defined flags, then stores the flags in the global state and returns the positional arguments.

Internal