forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResolverParser.hs
More file actions
40 lines (35 loc) · 1.24 KB
/
ResolverParser.hs
File metadata and controls
40 lines (35 loc) · 1.24 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
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
module Stack.Options.ResolverParser
( abstractResolverOptsParser
, compilerOptsParser
, readCompilerVersion
) where
import qualified Data.Text as T
import Options.Applicative
( Parser, ReadM, help, long, metavar, option, readerError )
import Options.Applicative.Types ( readerAsk )
import Stack.Options.Utils ( hideMods )
import Stack.Prelude
import Stack.Types.Resolver ( AbstractResolver, readAbstractResolver )
-- | Parser for the resolver
abstractResolverOptsParser :: Bool -> Parser (Unresolved AbstractResolver)
abstractResolverOptsParser hide = option readAbstractResolver
( long "resolver"
<> metavar "RESOLVER"
<> help "Override resolver in project file."
<> hideMods hide
)
compilerOptsParser :: Bool -> Parser WantedCompiler
compilerOptsParser hide = option readCompilerVersion
( long "compiler"
<> metavar "COMPILER"
<> help "Use the specified compiler."
<> hideMods hide
)
readCompilerVersion :: ReadM WantedCompiler
readCompilerVersion = do
s <- readerAsk
case parseWantedCompiler (T.pack s) of
Left{} -> readerError $ "Failed to parse compiler: " ++ s
Right x -> pure x