Compare commits

..

2 Commits

Author SHA1 Message Date
fa523d590e Add ListAvailable to ListCriteria 2021-09-24 20:51:29 +02:00
523f2f57e1 Fix ghcup list -t for hls/stack, fixes #244 2021-09-24 20:51:29 +02:00
3 changed files with 33 additions and 44 deletions

View File

@@ -824,7 +824,7 @@ listOpts =
<$> optional <$> optional
(option (option
(eitherReader toolParser) (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" "Tool to list versions for. Default is all"
) )
) )
@@ -833,8 +833,8 @@ listOpts =
(eitherReader criteriaParser) (eitherReader criteriaParser)
( short 'c' ( short 'c'
<> long "show-criteria" <> long "show-criteria"
<> metavar "<installed|set>" <> metavar "<installed|set|available>"
<> help "Show only installed or set tool versions" <> help "Show only installed/set/available tool versions"
) )
) )
<*> switch <*> switch
@@ -1429,6 +1429,8 @@ toolVersionEither s' =
toolParser :: String -> Either String Tool toolParser :: String -> Either String Tool
toolParser s' | t == T.pack "ghc" = Right GHC toolParser s' | t == T.pack "ghc" = Right GHC
| t == T.pack "cabal" = Right Cabal | t == T.pack "cabal" = Right Cabal
| t == T.pack "hls" = Right HLS
| t == T.pack "stack" = Right Stack
| otherwise = Left ("Unknown tool: " <> s') | otherwise = Left ("Unknown tool: " <> s')
where t = T.toLower (T.pack 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 :: String -> Either String ListCriteria
criteriaParser s' | t == T.pack "installed" = Right ListInstalled criteriaParser s' | t == T.pack "installed" = Right ListInstalled
| t == T.pack "set" = Right ListSet | t == T.pack "set" = Right ListSet
| t == T.pack "available" = Right ListAvailable
| otherwise = Left ("Unknown criteria: " <> s') | otherwise = Left ("Unknown criteria: " <> s')
where t = T.toLower (T.pack s') where t = T.toLower (T.pack s')

View File

@@ -1335,6 +1335,7 @@ warnAboutHlsCompatibility = do
-- | Filter data type for 'listVersions'. -- | Filter data type for 'listVersions'.
data ListCriteria = ListInstalled data ListCriteria = ListInstalled
| ListSet | ListSet
| ListAvailable
deriving Show deriving Show
-- | A list result describes a single tool version -- | A list result describes a single tool version
@@ -1677,6 +1678,7 @@ listVersions lt' criteria = do
Nothing -> lr Nothing -> lr
Just ListInstalled -> filter (\ListResult {..} -> lInstalled) lr Just ListInstalled -> filter (\ListResult {..} -> lInstalled) lr
Just ListSet -> filter (\ListResult {..} -> lSet) lr Just ListSet -> filter (\ListResult {..} -> lSet) lr
Just ListAvailable -> filter (\ListResult {..} -> not lNoBindist) lr

View File

@@ -52,57 +52,41 @@ esac
die() { die() {
if [ -n "${NO_COLOR}" ] ; then (>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1")
(>&2 printf "%s\\n" "$1")
else
(>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1")
fi
exit 2 exit 2
} }
warn() { warn() {
if [ -n "${NO_COLOR}" ] ; then case "${plat}" in
printf "%s\\n" "$1" MSYS*|MINGW*)
else echo -e "\\033[0;35m$1\\033[0m"
case "${plat}" in ;;
MSYS*|MINGW*) *)
echo -e "\\033[0;35m$1\\033[0m" printf "\\033[0;35m%s\\033[0m\\n" "$1"
;; ;;
*) esac
printf "\\033[0;35m%s\\033[0m\\n" "$1"
;;
esac
fi
} }
yellow() { yellow() {
if [ -n "${NO_COLOR}" ] ; then case "${plat}" in
printf "%s\\n" "$1" MSYS*|MINGW*)
else echo -e "\\033[0;33m$1\\033[0m"
case "${plat}" in ;;
MSYS*|MINGW*) *)
echo -e "\\033[0;33m$1\\033[0m" printf "\\033[0;33m%s\\033[0m\\n" "$1"
;; ;;
*) esac
printf "\\033[0;33m%s\\033[0m\\n" "$1"
;;
esac
fi
} }
green() { green() {
if [ -n "${NO_COLOR}" ] ; then case "${plat}" in
printf "%s\\n" "$1" MSYS*|MINGW*)
else echo -e "\\033[0;32m$1\\033[0m"
case "${plat}" in ;;
MSYS*|MINGW*) *)
echo -e "\\033[0;32m$1\\033[0m" printf "\\033[0;32m%s\\033[0m\\n" "$1"
;; ;;
*) esac
printf "\\033[0;32m%s\\033[0m\\n" "$1"
;;
esac
fi
} }
edo() { edo() {