minor tarball filter format change
This commit is contained in:
parent
62d5d53232
commit
53db68e39f
@ -14,7 +14,7 @@ import GHCup.Types
|
||||
import GHCup.Types.JSON ( )
|
||||
import GHCup.Utils.Logger
|
||||
|
||||
import Control.Monad
|
||||
import Data.Char ( toLower )
|
||||
#if !MIN_VERSION_base(4,13,0)
|
||||
import Data.Semigroup ( (<>) )
|
||||
#endif
|
||||
@ -68,15 +68,18 @@ validateYAMLOpts = ValidateYAMLOpts <$> optional inputP
|
||||
tarballFilterP :: Parser TarballFilter
|
||||
tarballFilterP = option readm $
|
||||
long "tarball-filter" <> short 'u' <> metavar "<tool>-<version>" <> value def
|
||||
<> help "Only check certain tarballs (format: <tool>-<version>, where <tool> is GHC by default)"
|
||||
<> help "Only check certain tarballs (format: <tool>-<version>)"
|
||||
where
|
||||
def = join TarballFilter $ makeRegex ("" :: String)
|
||||
def = TarballFilter Nothing (makeRegex ("" :: String))
|
||||
readm = do
|
||||
s <- str
|
||||
(t, v) <- case span (/= '-') s of
|
||||
(v, []) -> pure ("", v)
|
||||
(t, v) -> pure (t, drop 1 v)
|
||||
TarballFilter <$> makeRegexOptsM compIgnoreCase execBlank t <*> makeRegexM v
|
||||
case span (/= '-') s of
|
||||
(_, []) -> fail "invalid format, missing '-' after the tool name"
|
||||
(t, v) | [tool] <- [ tool | tool <- [minBound..maxBound], low (show tool) == low t ] ->
|
||||
TarballFilter <$> pure (Just tool) <*> makeRegexOptsM compIgnoreCase execBlank (drop 1 v)
|
||||
_ -> fail "invalid tool"
|
||||
low = fmap toLower
|
||||
|
||||
|
||||
opts :: Parser Options
|
||||
opts = Options <$> com
|
||||
|
@ -161,7 +161,7 @@ validate dls = do
|
||||
isBase _ = False
|
||||
|
||||
data TarballFilter = TarballFilter
|
||||
{ tfTool :: Regex
|
||||
{ tfTool :: Maybe Tool
|
||||
, tfVersion :: Regex
|
||||
}
|
||||
|
||||
@ -175,13 +175,13 @@ validateTarballs :: ( Monad m
|
||||
=> TarballFilter
|
||||
-> GHCupDownloads
|
||||
-> m ExitCode
|
||||
validateTarballs (TarballFilter toolRegex versionRegex) dls = do
|
||||
validateTarballs (TarballFilter tool versionRegex) dls = do
|
||||
ref <- liftIO $ newIORef 0
|
||||
|
||||
flip runReaderT ref $ do
|
||||
-- download/verify all tarballs
|
||||
let dlis = nubOrd $ dls ^.. each
|
||||
%& indices (matchTest toolRegex . show) %> each
|
||||
%& indices (maybe (const True) (==) tool) %> each
|
||||
%& indices (matchTest versionRegex . T.unpack . prettyVer)
|
||||
% (viSourceDL % _Just `summing` viArch % each % each % each)
|
||||
forM_ dlis $ downloadAll
|
||||
|
@ -79,7 +79,7 @@ data Tool = GHC
|
||||
| Cabal
|
||||
| GHCup
|
||||
| HLS
|
||||
deriving (Eq, GHC.Generic, Ord, Show)
|
||||
deriving (Eq, GHC.Generic, Ord, Show, Enum, Bounded)
|
||||
|
||||
|
||||
-- | All necessary information of a tool version, including
|
||||
|
Loading…
Reference in New Issue
Block a user