{-# LANGUAGE OverloadedStrings #-}
module PbtCli.Options (
Command (..),
SuitesOpts (..),
TestsOpts (..),
RunOpts (..),
ThreatModelsOpts (..),
DoctorOpts (..),
SuitesFormat (..),
TestsFormat (..),
RunOutput (..),
Filters (..),
parseCommand,
commandParserInfo,
) where
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Options.Applicative
import PbtCli.Version (versionLine)
data Command
= Suites SuitesOpts
| Tests TestsOpts
| Run RunOpts
| ThreatModels ThreatModelsOpts
| Doctor DoctorOpts
deriving (Command -> Command -> Bool
(Command -> Command -> Bool)
-> (Command -> Command -> Bool) -> Eq Command
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Command -> Command -> Bool
== :: Command -> Command -> Bool
$c/= :: Command -> Command -> Bool
/= :: Command -> Command -> Bool
Eq, Int -> Command -> ShowS
[Command] -> ShowS
Command -> String
(Int -> Command -> ShowS)
-> (Command -> String) -> ([Command] -> ShowS) -> Show Command
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Command -> ShowS
showsPrec :: Int -> Command -> ShowS
$cshow :: Command -> String
show :: Command -> String
$cshowList :: [Command] -> ShowS
showList :: [Command] -> ShowS
Show)
data SuitesFormat
=
SuitesList
|
SuitesJson
|
SuitesJsonCompact
|
SuitesTable
|
SuitesTsv
deriving (SuitesFormat -> SuitesFormat -> Bool
(SuitesFormat -> SuitesFormat -> Bool)
-> (SuitesFormat -> SuitesFormat -> Bool) -> Eq SuitesFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SuitesFormat -> SuitesFormat -> Bool
== :: SuitesFormat -> SuitesFormat -> Bool
$c/= :: SuitesFormat -> SuitesFormat -> Bool
/= :: SuitesFormat -> SuitesFormat -> Bool
Eq, Int -> SuitesFormat -> ShowS
[SuitesFormat] -> ShowS
SuitesFormat -> String
(Int -> SuitesFormat -> ShowS)
-> (SuitesFormat -> String)
-> ([SuitesFormat] -> ShowS)
-> Show SuitesFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SuitesFormat -> ShowS
showsPrec :: Int -> SuitesFormat -> ShowS
$cshow :: SuitesFormat -> String
show :: SuitesFormat -> String
$cshowList :: [SuitesFormat] -> ShowS
showList :: [SuitesFormat] -> ShowS
Show)
data TestsFormat
=
TestsList
|
TestsJson
|
TestsTree
deriving (TestsFormat -> TestsFormat -> Bool
(TestsFormat -> TestsFormat -> Bool)
-> (TestsFormat -> TestsFormat -> Bool) -> Eq TestsFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestsFormat -> TestsFormat -> Bool
== :: TestsFormat -> TestsFormat -> Bool
$c/= :: TestsFormat -> TestsFormat -> Bool
/= :: TestsFormat -> TestsFormat -> Bool
Eq, Int -> TestsFormat -> ShowS
[TestsFormat] -> ShowS
TestsFormat -> String
(Int -> TestsFormat -> ShowS)
-> (TestsFormat -> String)
-> ([TestsFormat] -> ShowS)
-> Show TestsFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestsFormat -> ShowS
showsPrec :: Int -> TestsFormat -> ShowS
$cshow :: TestsFormat -> String
show :: TestsFormat -> String
$cshowList :: [TestsFormat] -> ShowS
showList :: [TestsFormat] -> ShowS
Show)
data RunOutput
=
RunConsole
|
RunStream
|
RunJson
deriving (RunOutput -> RunOutput -> Bool
(RunOutput -> RunOutput -> Bool)
-> (RunOutput -> RunOutput -> Bool) -> Eq RunOutput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RunOutput -> RunOutput -> Bool
== :: RunOutput -> RunOutput -> Bool
$c/= :: RunOutput -> RunOutput -> Bool
/= :: RunOutput -> RunOutput -> Bool
Eq, Int -> RunOutput -> ShowS
[RunOutput] -> ShowS
RunOutput -> String
(Int -> RunOutput -> ShowS)
-> (RunOutput -> String)
-> ([RunOutput] -> ShowS)
-> Show RunOutput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RunOutput -> ShowS
showsPrec :: Int -> RunOutput -> ShowS
$cshow :: RunOutput -> String
show :: RunOutput -> String
$cshowList :: [RunOutput] -> ShowS
showList :: [RunOutput] -> ShowS
Show)
data Filters = Filters
{ Filters -> Maybe String
fltPattern :: Maybe String
, Filters -> Maybe String
fltTestIds :: Maybe String
, Filters -> Maybe String
fltThreatModelName :: Maybe String
, Filters -> [String]
fltTestOption :: [String]
}
deriving (Filters -> Filters -> Bool
(Filters -> Filters -> Bool)
-> (Filters -> Filters -> Bool) -> Eq Filters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Filters -> Filters -> Bool
== :: Filters -> Filters -> Bool
$c/= :: Filters -> Filters -> Bool
/= :: Filters -> Filters -> Bool
Eq, Int -> Filters -> ShowS
[Filters] -> ShowS
Filters -> String
(Int -> Filters -> ShowS)
-> (Filters -> String) -> ([Filters] -> ShowS) -> Show Filters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Filters -> ShowS
showsPrec :: Int -> Filters -> ShowS
$cshow :: Filters -> String
show :: Filters -> String
$cshowList :: [Filters] -> ShowS
showList :: [Filters] -> ShowS
Show)
data SuitesOpts = SuitesOpts
{ SuitesOpts -> String
suoRoot :: FilePath
, SuitesOpts -> SuitesFormat
suoFormat :: SuitesFormat
, SuitesOpts -> Bool
suoCompatibleOnly :: Bool
}
deriving (SuitesOpts -> SuitesOpts -> Bool
(SuitesOpts -> SuitesOpts -> Bool)
-> (SuitesOpts -> SuitesOpts -> Bool) -> Eq SuitesOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SuitesOpts -> SuitesOpts -> Bool
== :: SuitesOpts -> SuitesOpts -> Bool
$c/= :: SuitesOpts -> SuitesOpts -> Bool
/= :: SuitesOpts -> SuitesOpts -> Bool
Eq, Int -> SuitesOpts -> ShowS
[SuitesOpts] -> ShowS
SuitesOpts -> String
(Int -> SuitesOpts -> ShowS)
-> (SuitesOpts -> String)
-> ([SuitesOpts] -> ShowS)
-> Show SuitesOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SuitesOpts -> ShowS
showsPrec :: Int -> SuitesOpts -> ShowS
$cshow :: SuitesOpts -> String
show :: SuitesOpts -> String
$cshowList :: [SuitesOpts] -> ShowS
showList :: [SuitesOpts] -> ShowS
Show)
data TestsOpts = TestsOpts
{ TestsOpts -> String
tsoRoot :: FilePath
, TestsOpts -> Text
tsoSuite :: Text
, TestsOpts -> TestsFormat
tsoFormat :: TestsFormat
, TestsOpts -> Filters
tsoFilters :: Filters
, TestsOpts -> Bool
tsoDryRun :: Bool
}
deriving (TestsOpts -> TestsOpts -> Bool
(TestsOpts -> TestsOpts -> Bool)
-> (TestsOpts -> TestsOpts -> Bool) -> Eq TestsOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestsOpts -> TestsOpts -> Bool
== :: TestsOpts -> TestsOpts -> Bool
$c/= :: TestsOpts -> TestsOpts -> Bool
/= :: TestsOpts -> TestsOpts -> Bool
Eq, Int -> TestsOpts -> ShowS
[TestsOpts] -> ShowS
TestsOpts -> String
(Int -> TestsOpts -> ShowS)
-> (TestsOpts -> String)
-> ([TestsOpts] -> ShowS)
-> Show TestsOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestsOpts -> ShowS
showsPrec :: Int -> TestsOpts -> ShowS
$cshow :: TestsOpts -> String
show :: TestsOpts -> String
$cshowList :: [TestsOpts] -> ShowS
showList :: [TestsOpts] -> ShowS
Show)
data RunOpts = RunOpts
{ RunOpts -> String
rnoRoot :: FilePath
, RunOpts -> [Text]
rnoSuites :: [Text]
, RunOpts -> Bool
rnoCompatibleOnly :: Bool
, RunOpts -> RunOutput
rnoOutput :: RunOutput
, RunOpts -> Filters
rnoFilters :: Filters
, RunOpts -> Bool
rnoDryRun :: Bool
}
deriving (RunOpts -> RunOpts -> Bool
(RunOpts -> RunOpts -> Bool)
-> (RunOpts -> RunOpts -> Bool) -> Eq RunOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RunOpts -> RunOpts -> Bool
== :: RunOpts -> RunOpts -> Bool
$c/= :: RunOpts -> RunOpts -> Bool
/= :: RunOpts -> RunOpts -> Bool
Eq, Int -> RunOpts -> ShowS
[RunOpts] -> ShowS
RunOpts -> String
(Int -> RunOpts -> ShowS)
-> (RunOpts -> String) -> ([RunOpts] -> ShowS) -> Show RunOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RunOpts -> ShowS
showsPrec :: Int -> RunOpts -> ShowS
$cshow :: RunOpts -> String
show :: RunOpts -> String
$cshowList :: [RunOpts] -> ShowS
showList :: [RunOpts] -> ShowS
Show)
data ThreatModelsOpts = ThreatModelsOpts
{ ThreatModelsOpts -> String
tmoRoot :: FilePath
, ThreatModelsOpts -> Text
tmoSuite :: Text
, ThreatModelsOpts -> Bool
tmoJson :: Bool
, ThreatModelsOpts -> Bool
tmoDryRun :: Bool
}
deriving (ThreatModelsOpts -> ThreatModelsOpts -> Bool
(ThreatModelsOpts -> ThreatModelsOpts -> Bool)
-> (ThreatModelsOpts -> ThreatModelsOpts -> Bool)
-> Eq ThreatModelsOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ThreatModelsOpts -> ThreatModelsOpts -> Bool
== :: ThreatModelsOpts -> ThreatModelsOpts -> Bool
$c/= :: ThreatModelsOpts -> ThreatModelsOpts -> Bool
/= :: ThreatModelsOpts -> ThreatModelsOpts -> Bool
Eq, Int -> ThreatModelsOpts -> ShowS
[ThreatModelsOpts] -> ShowS
ThreatModelsOpts -> String
(Int -> ThreatModelsOpts -> ShowS)
-> (ThreatModelsOpts -> String)
-> ([ThreatModelsOpts] -> ShowS)
-> Show ThreatModelsOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ThreatModelsOpts -> ShowS
showsPrec :: Int -> ThreatModelsOpts -> ShowS
$cshow :: ThreatModelsOpts -> String
show :: ThreatModelsOpts -> String
$cshowList :: [ThreatModelsOpts] -> ShowS
showList :: [ThreatModelsOpts] -> ShowS
Show)
newtype DoctorOpts = DoctorOpts
{ DoctorOpts -> String
dcoRoot :: FilePath
}
deriving (DoctorOpts -> DoctorOpts -> Bool
(DoctorOpts -> DoctorOpts -> Bool)
-> (DoctorOpts -> DoctorOpts -> Bool) -> Eq DoctorOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DoctorOpts -> DoctorOpts -> Bool
== :: DoctorOpts -> DoctorOpts -> Bool
$c/= :: DoctorOpts -> DoctorOpts -> Bool
/= :: DoctorOpts -> DoctorOpts -> Bool
Eq, Int -> DoctorOpts -> ShowS
[DoctorOpts] -> ShowS
DoctorOpts -> String
(Int -> DoctorOpts -> ShowS)
-> (DoctorOpts -> String)
-> ([DoctorOpts] -> ShowS)
-> Show DoctorOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DoctorOpts -> ShowS
showsPrec :: Int -> DoctorOpts -> ShowS
$cshow :: DoctorOpts -> String
show :: DoctorOpts -> String
$cshowList :: [DoctorOpts] -> ShowS
showList :: [DoctorOpts] -> ShowS
Show)
commandParserInfo :: ParserInfo Command
commandParserInfo :: ParserInfo Command
commandParserInfo =
Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info
(Parser Command
parseCommand Parser Command -> Parser (Command -> Command) -> Parser Command
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser (Command -> Command)
forall a. Parser (a -> a)
helper Parser Command -> Parser (Command -> Command) -> Parser Command
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser (Command -> Command)
forall a. Parser (a -> a)
versionOption)
( InfoMod Command
forall a. InfoMod a
fullDesc
InfoMod Command -> InfoMod Command -> InfoMod Command
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod Command
forall a. String -> InfoMod a
progDesc
String
"Discover and run the test suites of a repository built on the \
\sc-testing-tools property-based testing stack."
InfoMod Command -> InfoMod Command -> InfoMod Command
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod Command
forall a. String -> InfoMod a
header String
"pbt-cli — a cabal test wrapper for sc-testing-tools suites"
InfoMod Command -> InfoMod Command -> InfoMod Command
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod Command
forall a. String -> InfoMod a
footer
String
"A suite is 'sc-testing-tools compatible' when its main-is uses \
\defaultMainStreaming / defaultMainTestingInterface, which is what \
\provides --list-tests-json, --streaming-json and the threat-model \
\options. Run 'pbt-cli <command> --help' for per-command options."
)
versionOption :: Parser (a -> a)
versionOption :: forall a. Parser (a -> a)
versionOption =
String -> Mod OptionFields (a -> a) -> Parser (a -> a)
forall a. String -> Mod OptionFields (a -> a) -> Parser (a -> a)
infoOption
String
versionLine
(String -> Mod OptionFields (a -> a)
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"version" Mod OptionFields (a -> a)
-> Mod OptionFields (a -> a) -> Mod OptionFields (a -> a)
forall a. Semigroup a => a -> a -> a
<> Char -> Mod OptionFields (a -> a)
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'V' Mod OptionFields (a -> a)
-> Mod OptionFields (a -> a) -> Mod OptionFields (a -> a)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (a -> a)
forall (f :: * -> *) a. String -> Mod f a
help String
"Print the version and target platform, then exit")
parseCommand :: Parser Command
parseCommand :: Parser Command
parseCommand =
Mod CommandFields Command -> Parser Command
forall a. Mod CommandFields a -> Parser a
hsubparser
( String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command
String
"suites"
( Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info
(SuitesOpts -> Command
Suites (SuitesOpts -> Command) -> Parser SuitesOpts -> Parser Command
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser SuitesOpts
suitesOpts)
( String -> InfoMod Command
forall a. String -> InfoMod a
progDesc
String
"Discover test suites without compiling anything, and report which are \
\sc-testing-tools compatible"
)
)
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command
String
"tests"
( Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info
(TestsOpts -> Command
Tests (TestsOpts -> Command) -> Parser TestsOpts -> Parser Command
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser TestsOpts
testsOpts)
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"List the tests inside one suite (authoritative; builds the suite)")
)
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command
String
"run"
( Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info
(RunOpts -> Command
Run (RunOpts -> Command) -> Parser RunOpts -> Parser Command
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser RunOpts
runOpts)
( String -> InfoMod Command
forall a. String -> InfoMod a
progDesc
String
"Run every suite, or just the named ones; --stream renders the \
\streaming events live and --json forwards them as NDJSON"
)
)
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command
String
"threat-models"
( Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info
(ThreatModelsOpts -> Command
ThreatModels (ThreatModelsOpts -> Command)
-> Parser ThreatModelsOpts -> Parser Command
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ThreatModelsOpts
threatModelsOpts)
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"List the threat models a suite can run")
)
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command
String
"doctor"
( Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info
(DoctorOpts -> Command
Doctor (DoctorOpts -> Command) -> Parser DoctorOpts -> Parser Command
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser DoctorOpts
doctorOpts)
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"Check that everything pbt-cli needs is present and the repo is discoverable")
)
)
rootOption :: Parser FilePath
rootOption :: Parser String
rootOption =
Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
( String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"root"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Char -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'C'
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"DIR"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasValue f => a -> Mod f a
value String
"."
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall a (f :: * -> *). Show a => Mod f a
showDefault
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Repository root to scan and run cabal in"
)
rootWithPositional :: Parser FilePath
rootWithPositional :: Parser String
rootWithPositional =
String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe
(String -> Maybe String -> String)
-> Parser String -> Parser (Maybe String -> String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
rootOption
Parser (Maybe String -> String)
-> Parser (Maybe String) -> Parser String
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser String -> Parser (Maybe String)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
( Mod ArgumentFields String -> Parser String
forall s. IsString s => Mod ArgumentFields s -> Parser s
strArgument
( String -> Mod ArgumentFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"[ROOT]"
Mod ArgumentFields String
-> Mod ArgumentFields String -> Mod ArgumentFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod ArgumentFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Repository root to scan (positional alternative to --root)"
)
)
suiteArgument :: Parser Text
suiteArgument :: Parser Text
suiteArgument =
Mod ArgumentFields Text -> Parser Text
forall s. IsString s => Mod ArgumentFields s -> Parser s
strArgument
( String -> Mod ArgumentFields Text
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"SUITE"
Mod ArgumentFields Text
-> Mod ArgumentFields Text -> Mod ArgumentFields Text
forall a. Semigroup a => a -> a -> a
<> String -> Mod ArgumentFields Text
forall (f :: * -> *) a. String -> Mod f a
help String
"Test-suite name, as reported by 'pbt-cli suites'"
)
dryRunSwitch :: Parser Bool
dryRunSwitch :: Parser Bool
dryRunSwitch =
Mod FlagFields Bool -> Parser Bool
switch
( String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"dry-run"
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Print the cabal command(s) that would run, and exit"
)
compatibleOnlySwitch :: Parser Bool
compatibleOnlySwitch :: Parser Bool
compatibleOnlySwitch =
Mod FlagFields Bool -> Parser Bool
switch
( String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"compatible-only"
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Consider only sc-testing-tools compatible (streaming) suites"
)
filtersParser :: Parser Filters
filtersParser :: Parser Filters
filtersParser =
Maybe String -> Maybe String -> Maybe String -> [String] -> Filters
Filters
(Maybe String
-> Maybe String -> Maybe String -> [String] -> Filters)
-> Parser (Maybe String)
-> Parser (Maybe String -> Maybe String -> [String] -> Filters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String -> Parser (Maybe String)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
( String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"pattern"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Char -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'p'
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"PAT"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Tasty pattern: run only tests whose name or path matches"
)
)
Parser (Maybe String -> Maybe String -> [String] -> Filters)
-> Parser (Maybe String)
-> Parser (Maybe String -> [String] -> Filters)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser String -> Parser (Maybe String)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
( String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"test-id"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"IDS"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Comma-separated test ids to run (discover them with 'pbt-cli tests')"
)
)
Parser (Maybe String -> [String] -> Filters)
-> Parser (Maybe String) -> Parser ([String] -> Filters)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser String -> Parser (Maybe String)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
( String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"threat-model-name"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"NAMES"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Comma-separated threat-model name prefixes to run"
)
)
Parser ([String] -> Filters) -> Parser [String] -> Parser Filters
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser String -> Parser [String]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many
( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
( String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"test-option"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"OPT"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Extra option to pass through to the test binary verbatim (repeatable)"
)
)
suitesOpts :: Parser SuitesOpts
suitesOpts :: Parser SuitesOpts
suitesOpts =
String -> SuitesFormat -> Bool -> SuitesOpts
SuitesOpts
(String -> SuitesFormat -> Bool -> SuitesOpts)
-> Parser String -> Parser (SuitesFormat -> Bool -> SuitesOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
rootWithPositional
Parser (SuitesFormat -> Bool -> SuitesOpts)
-> Parser SuitesFormat -> Parser (Bool -> SuitesOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser SuitesFormat
suitesFormat
Parser (Bool -> SuitesOpts) -> Parser Bool -> Parser SuitesOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
compatibleOnlySwitch
suitesFormat :: Parser SuitesFormat
suitesFormat :: Parser SuitesFormat
suitesFormat =
SuitesFormat -> Mod FlagFields SuitesFormat -> Parser SuitesFormat
forall a. a -> Mod FlagFields a -> Parser a
flag' SuitesFormat
SuitesJson (String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"json" Mod FlagFields SuitesFormat
-> Mod FlagFields SuitesFormat -> Mod FlagFields SuitesFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. String -> Mod f a
help String
"The full discovery document as indented JSON")
Parser SuitesFormat -> Parser SuitesFormat -> Parser SuitesFormat
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SuitesFormat -> Mod FlagFields SuitesFormat -> Parser SuitesFormat
forall a. a -> Mod FlagFields a -> Parser a
flag' SuitesFormat
SuitesJsonCompact (String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"compact" Mod FlagFields SuitesFormat
-> Mod FlagFields SuitesFormat -> Mod FlagFields SuitesFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. String -> Mod f a
help String
"The discovery document as single-line JSON")
Parser SuitesFormat -> Parser SuitesFormat -> Parser SuitesFormat
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SuitesFormat -> Mod FlagFields SuitesFormat -> Parser SuitesFormat
forall a. a -> Mod FlagFields a -> Parser a
flag' SuitesFormat
SuitesTable (String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"table" Mod FlagFields SuitesFormat
-> Mod FlagFields SuitesFormat -> Mod FlagFields SuitesFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. String -> Mod f a
help String
"Aligned table with package, compatibility and main-is")
Parser SuitesFormat -> Parser SuitesFormat -> Parser SuitesFormat
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SuitesFormat -> Mod FlagFields SuitesFormat -> Parser SuitesFormat
forall a. a -> Mod FlagFields a -> Parser a
flag' SuitesFormat
SuitesTsv (String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"tsv" Mod FlagFields SuitesFormat
-> Mod FlagFields SuitesFormat -> Mod FlagFields SuitesFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields SuitesFormat
forall (f :: * -> *) a. String -> Mod f a
help String
"Legacy 5-column tab-separated output")
Parser SuitesFormat -> Parser SuitesFormat -> Parser SuitesFormat
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SuitesFormat -> Parser SuitesFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuitesFormat
SuitesList
testsOpts :: Parser TestsOpts
testsOpts :: Parser TestsOpts
testsOpts =
String -> Text -> TestsFormat -> Filters -> Bool -> TestsOpts
TestsOpts
(String -> Text -> TestsFormat -> Filters -> Bool -> TestsOpts)
-> Parser String
-> Parser (Text -> TestsFormat -> Filters -> Bool -> TestsOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
rootOption
Parser (Text -> TestsFormat -> Filters -> Bool -> TestsOpts)
-> Parser Text
-> Parser (TestsFormat -> Filters -> Bool -> TestsOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Text
suiteArgument
Parser (TestsFormat -> Filters -> Bool -> TestsOpts)
-> Parser TestsFormat -> Parser (Filters -> Bool -> TestsOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser TestsFormat
testsFormat
Parser (Filters -> Bool -> TestsOpts)
-> Parser Filters -> Parser (Bool -> TestsOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Filters
filtersParser
Parser (Bool -> TestsOpts) -> Parser Bool -> Parser TestsOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
dryRunSwitch
testsFormat :: Parser TestsFormat
testsFormat :: Parser TestsFormat
testsFormat =
TestsFormat -> Mod FlagFields TestsFormat -> Parser TestsFormat
forall a. a -> Mod FlagFields a -> Parser a
flag' TestsFormat
TestsJson (String -> Mod FlagFields TestsFormat
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"json" Mod FlagFields TestsFormat
-> Mod FlagFields TestsFormat -> Mod FlagFields TestsFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields TestsFormat
forall (f :: * -> *) a. String -> Mod f a
help String
"The suite's own suite_started payload, verbatim")
Parser TestsFormat -> Parser TestsFormat -> Parser TestsFormat
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TestsFormat -> Mod FlagFields TestsFormat -> Parser TestsFormat
forall a. a -> Mod FlagFields a -> Parser a
flag' TestsFormat
TestsTree (String -> Mod FlagFields TestsFormat
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"tree" Mod FlagFields TestsFormat
-> Mod FlagFields TestsFormat -> Mod FlagFields TestsFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields TestsFormat
forall (f :: * -> *) a. String -> Mod f a
help String
"Nested groups with test ids")
Parser TestsFormat -> Parser TestsFormat -> Parser TestsFormat
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TestsFormat -> Parser TestsFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TestsFormat
TestsList
runOpts :: Parser RunOpts
runOpts :: Parser RunOpts
runOpts =
String -> [Text] -> Bool -> RunOutput -> Filters -> Bool -> RunOpts
RunOpts
(String
-> [Text] -> Bool -> RunOutput -> Filters -> Bool -> RunOpts)
-> Parser String
-> Parser
([Text] -> Bool -> RunOutput -> Filters -> Bool -> RunOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
rootOption
Parser ([Text] -> Bool -> RunOutput -> Filters -> Bool -> RunOpts)
-> Parser [Text]
-> Parser (Bool -> RunOutput -> Filters -> Bool -> RunOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Text -> Parser [Text]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many
( Mod ArgumentFields Text -> Parser Text
forall s. IsString s => Mod ArgumentFields s -> Parser s
strArgument
( String -> Mod ArgumentFields Text
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"SUITE..."
Mod ArgumentFields Text
-> Mod ArgumentFields Text -> Mod ArgumentFields Text
forall a. Semigroup a => a -> a -> a
<> String -> Mod ArgumentFields Text
forall (f :: * -> *) a. String -> Mod f a
help String
"Suites to run; omit to run every discovered suite"
)
)
Parser (Bool -> RunOutput -> Filters -> Bool -> RunOpts)
-> Parser Bool -> Parser (RunOutput -> Filters -> Bool -> RunOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
compatibleOnlySwitch
Parser (RunOutput -> Filters -> Bool -> RunOpts)
-> Parser RunOutput -> Parser (Filters -> Bool -> RunOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser RunOutput
runOutput
Parser (Filters -> Bool -> RunOpts)
-> Parser Filters -> Parser (Bool -> RunOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Filters
filtersParser
Parser (Bool -> RunOpts) -> Parser Bool -> Parser RunOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
dryRunSwitch
runOutput :: Parser RunOutput
runOutput :: Parser RunOutput
runOutput =
RunOutput -> Mod FlagFields RunOutput -> Parser RunOutput
forall a. a -> Mod FlagFields a -> Parser a
flag'
RunOutput
RunJson
( String -> Mod FlagFields RunOutput
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"json"
Mod FlagFields RunOutput
-> Mod FlagFields RunOutput -> Mod FlagFields RunOutput
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields RunOutput
forall (f :: * -> *) a. String -> Mod f a
help String
"Emit the streaming events as NDJSON, each tagged with its suite"
)
Parser RunOutput -> Parser RunOutput -> Parser RunOutput
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> RunOutput -> Mod FlagFields RunOutput -> Parser RunOutput
forall a. a -> Mod FlagFields a -> Parser a
flag'
RunOutput
RunStream
( String -> Mod FlagFields RunOutput
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"stream"
Mod FlagFields RunOutput
-> Mod FlagFields RunOutput -> Mod FlagFields RunOutput
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields RunOutput
forall (f :: * -> *) a. String -> Mod f a
help String
"Render the streaming events live, instead of cabal's console output"
)
Parser RunOutput -> Parser RunOutput -> Parser RunOutput
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> RunOutput -> Parser RunOutput
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure RunOutput
RunConsole
threatModelsOpts :: Parser ThreatModelsOpts
threatModelsOpts :: Parser ThreatModelsOpts
threatModelsOpts =
String -> Text -> Bool -> Bool -> ThreatModelsOpts
ThreatModelsOpts
(String -> Text -> Bool -> Bool -> ThreatModelsOpts)
-> Parser String
-> Parser (Text -> Bool -> Bool -> ThreatModelsOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
rootOption
Parser (Text -> Bool -> Bool -> ThreatModelsOpts)
-> Parser Text -> Parser (Bool -> Bool -> ThreatModelsOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Text
suiteArgument
Parser (Bool -> Bool -> ThreatModelsOpts)
-> Parser Bool -> Parser (Bool -> ThreatModelsOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Mod FlagFields Bool -> Parser Bool
switch (String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"json" Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Emit the suite's JSON payload instead of one name per line")
Parser (Bool -> ThreatModelsOpts)
-> Parser Bool -> Parser ThreatModelsOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
dryRunSwitch
doctorOpts :: Parser DoctorOpts
doctorOpts :: Parser DoctorOpts
doctorOpts = String -> DoctorOpts
DoctorOpts (String -> DoctorOpts) -> Parser String -> Parser DoctorOpts
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
rootWithPositional