From 523f2f57e11c16ff01ae2614321baccb4ab876c4 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 24 Sep 2021 20:49:03 +0200 Subject: [PATCH 1/2] Fix `ghcup list -t` for hls/stack, fixes #244 --- app/ghcup/Main.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs index 48b326d..bdf0f6e 100644 --- a/app/ghcup/Main.hs +++ b/app/ghcup/Main.hs @@ -824,7 +824,7 @@ listOpts = <$> optional (option (eitherReader toolParser) - (short 't' <> long "tool" <> metavar "" <> help + (short 't' <> long "tool" <> metavar "" <> help "Tool to list versions for. Default is all" ) ) @@ -1429,6 +1429,8 @@ toolVersionEither s' = toolParser :: String -> Either String Tool toolParser s' | t == T.pack "ghc" = Right GHC | t == T.pack "cabal" = Right Cabal + | t == T.pack "hls" = Right HLS + | t == T.pack "stack" = Right Stack | otherwise = Left ("Unknown tool: " <> s') where t = T.toLower (T.pack s') From fa523d590ece57cfddd7a0b47d9740f3367aeae0 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 24 Sep 2021 20:49:32 +0200 Subject: [PATCH 2/2] Add ListAvailable to ListCriteria --- app/ghcup/Main.hs | 5 +++-- lib/GHCup.hs | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs index bdf0f6e..74e4fca 100644 --- a/app/ghcup/Main.hs +++ b/app/ghcup/Main.hs @@ -833,8 +833,8 @@ listOpts = (eitherReader criteriaParser) ( short 'c' <> long "show-criteria" - <> metavar "" - <> help "Show only installed or set tool versions" + <> metavar "" + <> help "Show only installed/set/available tool versions" ) ) <*> switch @@ -1438,6 +1438,7 @@ toolParser s' | t == T.pack "ghc" = Right GHC criteriaParser :: String -> Either String ListCriteria criteriaParser s' | t == T.pack "installed" = Right ListInstalled | t == T.pack "set" = Right ListSet + | t == T.pack "available" = Right ListAvailable | otherwise = Left ("Unknown criteria: " <> s') where t = T.toLower (T.pack s') diff --git a/lib/GHCup.hs b/lib/GHCup.hs index e3c6543..3ed9f35 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -1335,6 +1335,7 @@ warnAboutHlsCompatibility = do -- | Filter data type for 'listVersions'. data ListCriteria = ListInstalled | ListSet + | ListAvailable deriving Show -- | A list result describes a single tool version @@ -1677,6 +1678,7 @@ listVersions lt' criteria = do Nothing -> lr Just ListInstalled -> filter (\ListResult {..} -> lInstalled) lr Just ListSet -> filter (\ListResult {..} -> lSet) lr + Just ListAvailable -> filter (\ListResult {..} -> not lNoBindist) lr