Merge branch 'issue-244'

This commit is contained in:
Julian Ospald 2021-09-24 23:19:35 +02:00
commit 7982f3aec0
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F
2 changed files with 8 additions and 3 deletions

View File

@ -824,7 +824,7 @@ listOpts =
<$> optional
(option
(eitherReader toolParser)
(short 't' <> long "tool" <> metavar "<ghc|cabal>" <> help
(short 't' <> long "tool" <> metavar "<ghc|cabal|hls|stack>" <> help
"Tool to list versions for. Default is all"
)
)
@ -833,8 +833,8 @@ listOpts =
(eitherReader criteriaParser)
( short 'c'
<> long "show-criteria"
<> metavar "<installed|set>"
<> help "Show only installed or set tool versions"
<> metavar "<installed|set|available>"
<> help "Show only installed/set/available tool versions"
)
)
<*> switch
@ -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')
@ -1436,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')

View File

@ -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