adds basic --isolate option structure for install commands

This commit is contained in:
Arjun Kathuria 2021-07-20 22:05:01 +05:30
parent 88d1d19f55
commit 521ab0aedb

View File

@ -138,6 +138,7 @@ data InstallOptions = InstallOptions
, instPlatform :: Maybe PlatformRequest
, instBindist :: Maybe URI
, instSet :: Bool
, isolateDir :: Maybe FilePath
}
data SetCommand = SetGHC SetOptions
@ -574,7 +575,7 @@ Examples:
installOpts :: Maybe Tool -> Parser InstallOptions
installOpts tool =
(\p (u, v) b -> InstallOptions v p u b)
(\p (u, v) b is -> InstallOptions v p u b is)
<$> optional
(option
(eitherReader platformParser)
@ -603,6 +604,15 @@ installOpts tool =
(long "set" <> help
"Set as active version after install"
)
<*> optional
(option
(eitherReader isolateParser)
( short 'i'
<> long "isolate"
<> metavar "DIR"
<> help "install in an isolated dir instead of the default one"
)
)
setParser :: Parser (Either SetCommand SetOptions)
@ -1215,6 +1225,10 @@ platformParser s' = case MP.parse (platformP <* MP.eof) "" (T.pack s') of
bindistParser :: String -> Either String URI
bindistParser = first show . parseURI strictURIParserOptions . UTF8.fromString
isolateParser :: FilePath -> Either String FilePath
isolateParser f = case isValid f of
True -> Right $ normalise f
False -> Left "Please enter a valid filepath for isolate dir."
toSettings :: Options -> IO (Settings, KeyBindings)
toSettings options = do