{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
module Stack.Options.ResolverParser where
import qualified Data.Text as T
import Options.Applicative
import Options.Applicative.Types (readerAsk)
import Stack.Options.Utils
import Stack.Prelude
import Stack.Types.Resolver
abstractResolverOptsParser :: Bool -> Parser (Unresolved AbstractResolver)
abstractResolverOptsParser :: Bool -> Parser (Unresolved AbstractResolver)
abstractResolverOptsParser Bool
hide =
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM (Unresolved AbstractResolver)
readAbstractResolver
(forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"resolver" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"RESOLVER" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. String -> Mod f a
help String
"Override resolver in project file" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. Bool -> Mod f a
hideMods Bool
hide)
compilerOptsParser :: Bool -> Parser WantedCompiler
compilerOptsParser :: Bool -> Parser WantedCompiler
compilerOptsParser Bool
hide =
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM WantedCompiler
readCompilerVersion
(forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"compiler" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"COMPILER" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. String -> Mod f a
help String
"Use the specified compiler" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. Bool -> Mod f a
hideMods Bool
hide)
readCompilerVersion :: ReadM WantedCompiler
readCompilerVersion :: ReadM WantedCompiler
readCompilerVersion = do
String
s <- ReadM String
readerAsk
case Text -> Either PantryException WantedCompiler
parseWantedCompiler (String -> Text
T.pack String
s) of
Left{} -> forall a. String -> ReadM a
readerError forall a b. (a -> b) -> a -> b
$ String
"Failed to parse compiler: " forall a. [a] -> [a] -> [a]
++ String
s
Right WantedCompiler
x -> forall (m :: * -> *) a. Monad m => a -> m a
return WantedCompiler
x