Merge pull request #10428 from 9999years/add-validate-tasty-arg
[cabal.git] / cabal-validate / src / Step.hs
blob2636f483a79903b202fc3c702524f774535fe952
1 -- | The steps that can be run by @cabal-validate@.
2 module Step
3 ( Step (..)
4 , displayStep
5 , nameToStep
6 , parseStep
7 ) where
9 import Data.Map.Strict (Map)
10 import qualified Data.Map.Strict as Map
12 -- | A step to be run by @cabal-validate@.
13 data Step
14 = PrintConfig
15 | PrintToolVersions
16 | Build
17 | Doctest
18 | LibTests
19 | LibSuite
20 | LibSuiteExtras
21 | CliTests
22 | CliSuite
23 | SolverBenchmarksTests
24 | SolverBenchmarksRun
25 | TimeSummary
26 deriving (Eq, Enum, Bounded, Show)
28 -- | Get the display identifier for a given `Step`.
30 -- This is used to parse the @--step@ command-line argument.
32 -- Note that these names are just kebab-case variants of the `Step` constructor
33 -- names; they do not attempt to describe the steps.
34 displayStep :: Step -> String
35 displayStep step =
36 case step of
37 PrintConfig -> "print-config"
38 PrintToolVersions -> "print-tool-versions"
39 Build -> "build"
40 Doctest -> "doctest"
41 LibTests -> "lib-tests"
42 LibSuite -> "lib-suite"
43 LibSuiteExtras -> "lib-suite-extras"
44 CliTests -> "cli-tests"
45 CliSuite -> "cli-suite"
46 SolverBenchmarksTests -> "solver-benchmarks-tests"
47 SolverBenchmarksRun -> "solver-benchmarks-run"
48 TimeSummary -> "time-summary"
50 -- | A map from step names to `Steps`.
52 -- This is an inverse of `displayStep`.
53 nameToStep :: Map String Step
54 nameToStep =
55 Map.fromList
56 [ (displayStep step, step)
57 | step <- [minBound .. maxBound]
60 -- | Parse a string as a `Step`.
61 parseStep :: String -> Maybe Step
62 parseStep step = Map.lookup step nameToStep