| 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 { }
- | RequiredFlag { }
- | OptionalFlag { }
- | MultiFlag {
- type_ :: FlagType x
- parseMulti :: [x] -> Either String a
- data FlagType x where
- getFlag :: forall a m. (MonadIO m, IsFlag a) => m a
- loadCliArgs :: [Flag] -> [Flag] -> IO TestTargets
- newtype ANSIFlag = ANSIFlag (Maybe Bool)
- data FormatFlag
- getFormatFlag :: IO FormatFlag
- parseCliArgsWith :: FlagInfos -> [String] -> CLIParseResult
- type FlagInfos = [(Text, Maybe Char, SomeFlagSpec)]
- data SomeFlagSpec = Typeable a => SomeFlagSpec (FlagSpec a)
- data CLIParseResult
- = CLISetupFailure Text
- | CLIHelpRequested
- | CLIParseFailure Text
- | CLIParseSuccess {
- testTargets :: TestTargets
- flagStore :: CLIFlagStore
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
{ default_ = "foo"
, parse = 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.
Constructors
| SwitchFlag | |
| RequiredFlag | |
| OptionalFlag | |
| MultiFlag | |
Fields
| |
data FlagType x where Source #
Constructors
| FlagType_Switch :: FlagType Bool | |
| FlagType_Arg :: FlagType [Char] |
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.
General flags
data FormatFlag Source #
Constructors
| FormatFlag_Minimal | |
| FormatFlag_Full | |
| FormatFlag_Verbose |
Instances
| Show FormatFlag Source # | |
Defined in Skeletest.Internal.CLI Methods showsPrec :: Int -> FormatFlag -> ShowS # show :: FormatFlag -> String # showList :: [FormatFlag] -> ShowS # | |
| Eq FormatFlag Source # | |
Defined in Skeletest.Internal.CLI | |
| IsFlag (Maybe FormatFlag) Source # | |
Internal
parseCliArgsWith :: FlagInfos -> [String] -> CLIParseResult Source #
data SomeFlagSpec Source #
Constructors
| Typeable a => SomeFlagSpec (FlagSpec a) |
data CLIParseResult Source #
Constructors
| CLISetupFailure Text | |
| CLIHelpRequested | |
| CLIParseFailure Text | |
| CLIParseSuccess | |
Fields
| |