Safe Haskell | None |
---|---|
Language | GHC2021 |
Skeletest.Internal.CLI
Contents
Synopsis
- data Flag = IsFlag a => Flag (Proxy a)
- flag :: IsFlag a => Flag
- class Typeable a => IsFlag a where
- data FlagSpec a
- = SwitchFlag {
- flagFromBool :: Bool -> a
- | RequiredFlag { }
- | OptionalFlag {
- flagDefault :: a
- flagParse :: String -> Either String a
- = SwitchFlag {
- getFlag :: forall a m. (MonadIO m, IsFlag a) => m a
- loadCliArgs :: [Flag] -> [Flag] -> IO TestTargets
- parseCliArgs :: [Flag] -> [String] -> CLIParseResult
- data CLIParseResult
- type CLIFlagStore = Map TypeRep Dynamic
Documentation
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 ]
class Typeable a => IsFlag a where Source #
Methods
flagShort :: Maybe Char Source #
flagMetaVar :: String Source #
The placeholder for the flag to show in the help text, if the flag takes an argument.
Instances
Constructors
SwitchFlag | |
Fields
| |
RequiredFlag | |
OptionalFlag | |
Fields
|
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
parseCliArgs :: [Flag] -> [String] -> CLIParseResult Source #
data CLIParseResult Source #
Constructors
CLISetupFailure Text | |
CLIHelpRequested | |
CLIParseFailure Text | |
CLIParseSuccess | |
Fields |