Respect the user's configuration settings
Only lookup user configuration before doing a search; implement version completion for Cabal and HLS removal
This commit is contained in:
parent
1a5f0259f4
commit
453a29fdf7
@ -596,14 +596,14 @@ rmParser =
|
|||||||
<> command
|
<> command
|
||||||
"cabal"
|
"cabal"
|
||||||
( RmCabal
|
( RmCabal
|
||||||
<$> (info (versionParser' <**> helper)
|
<$> (info (versionParser' False (Just ListInstalled) (Just Cabal) <**> helper)
|
||||||
(progDesc "Remove Cabal version")
|
(progDesc "Remove Cabal version")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
<> command
|
<> command
|
||||||
"hls"
|
"hls"
|
||||||
( RmHLS
|
( RmHLS
|
||||||
<$> (info (versionParser' <**> helper)
|
<$> (info (versionParser' False (Just ListInstalled) (Just HLS) <**> helper)
|
||||||
(progDesc "Remove haskell-language-server version")
|
(progDesc "Remove haskell-language-server version")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -795,6 +795,11 @@ versionCompleter networkSensitive criteria tool =
|
|||||||
runLogger =
|
runLogger =
|
||||||
myLoggerT loggerConfig
|
myLoggerT loggerConfig
|
||||||
|
|
||||||
|
downloadWithUserSource = do
|
||||||
|
userConf <- runE @'[ JSONError ] ghcupConfigFile
|
||||||
|
getDownloadsF $
|
||||||
|
veitherCont (const GHCupURL) (fromMaybe GHCupURL . uUrlSource) userConf
|
||||||
|
|
||||||
mpFreq <-
|
mpFreq <-
|
||||||
runLogger . runE $
|
runLogger . runE $
|
||||||
platformRequest
|
platformRequest
|
||||||
@ -811,11 +816,11 @@ versionCompleter networkSensitive criteria tool =
|
|||||||
|
|
||||||
mGhcUpInfo <-
|
mGhcUpInfo <-
|
||||||
runEnv . runE $
|
runEnv . runE $
|
||||||
if networkSensitive then
|
if networkSensitive then do
|
||||||
getDownloadsF GHCupURL
|
downloadWithUserSource
|
||||||
else
|
else
|
||||||
catchE
|
catchE
|
||||||
(\(FileDoesNotExistError _) -> getDownloadsF GHCupURL)
|
(\(FileDoesNotExistError _) -> downloadWithUserSource)
|
||||||
readFromCache
|
readFromCache
|
||||||
|
|
||||||
forFold mGhcUpInfo $ \(GHCupInfo _ dls) -> do
|
forFold mGhcUpInfo $ \(GHCupInfo _ dls) -> do
|
||||||
@ -833,10 +838,10 @@ versionParser = option
|
|||||||
(short 'v' <> long "version" <> metavar "VERSION" <> help "The target version"
|
(short 'v' <> long "version" <> metavar "VERSION" <> help "The target version"
|
||||||
)
|
)
|
||||||
|
|
||||||
versionParser' :: Parser Version
|
versionParser' :: Bool -> Maybe ListCriteria -> Maybe Tool -> Parser Version
|
||||||
versionParser' = argument
|
versionParser' networkSensitive criteria tool = argument
|
||||||
(eitherReader (first show . version . T.pack))
|
(eitherReader (first show . version . T.pack))
|
||||||
(metavar "VERSION")
|
(metavar "VERSION" <> foldMap (completer . versionCompleter networkSensitive criteria) tool)
|
||||||
|
|
||||||
|
|
||||||
tagEither :: String -> Either String Tag
|
tagEither :: String -> Either String Tag
|
||||||
|
@ -185,9 +185,9 @@ getDirs = do
|
|||||||
ghcupConfigFile :: (MonadIO m)
|
ghcupConfigFile :: (MonadIO m)
|
||||||
=> Excepts '[JSONError] m UserSettings
|
=> Excepts '[JSONError] m UserSettings
|
||||||
ghcupConfigFile = do
|
ghcupConfigFile = do
|
||||||
confDir <- liftIO $ ghcupConfigDir
|
confDir <- liftIO ghcupConfigDir
|
||||||
let file = confDir </> [rel|config.yaml|]
|
let file = confDir </> [rel|config.yaml|]
|
||||||
bs <- liftIO $ handleIO' NoSuchThing (\_ -> pure $ Nothing) $ fmap Just $ readFile file
|
bs <- liftIO $ handleIO' NoSuchThing (\_ -> pure Nothing) $ Just <$> readFile file
|
||||||
case bs of
|
case bs of
|
||||||
Nothing -> pure defaultUserSettings
|
Nothing -> pure defaultUserSettings
|
||||||
Just bs' -> lE' JSONDecodeError . bimap show id . Y.decodeEither' . L.toStrict $ bs'
|
Just bs' -> lE' JSONDecodeError . bimap show id . Y.decodeEither' . L.toStrict $ bs'
|
||||||
|
Loading…
Reference in New Issue
Block a user