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