forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHpcReportParser.hs
More file actions
41 lines (38 loc) · 1.64 KB
/
HpcReportParser.hs
File metadata and controls
41 lines (38 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{-# LANGUAGE NoImplicitPrelude #-}
module Stack.Options.HpcReportParser where
import qualified Data.Text as T
import Options.Applicative
import Options.Applicative.Builder.Extra
import Options.Applicative.Types (readerAsk)
import Stack.Coverage (HpcReportOpts (..))
import Stack.Options.Completion (targetCompleter)
import Stack.Prelude
import Stack.Types.Config
-- | Parser for @stack hpc report@.
hpcReportOptsParser :: Parser HpcReportOpts
hpcReportOptsParser = HpcReportOpts
<$> many (textArgument $ metavar "TARGET_OR_TIX" <>
completer (targetCompleter <> fileExtCompleter [".tix"]))
<*> switch (long "all" <> help "Use results from all packages and components involved in previous --coverage run")
<*> optional (strOption (long "destdir" <>
metavar "DIR" <>
completer dirCompleter <>
help "Output directory for HTML report"))
<*> switch (long "open" <> help "Open the report in the browser")
pvpBoundsOption :: Parser PvpBounds
pvpBoundsOption =
option
readPvpBounds
(long "pvp-bounds" <>
metavar "PVP-BOUNDS" <>
completeWith ["none", "lower", "upper", "both"] <>
help
"How PVP version bounds should be added to .cabal file: none, lower, upper, both")
where
readPvpBounds = do
s <- readerAsk
case parsePvpBounds $ T.pack s of
Left e ->
readerError e
Right v ->
return v