2023-07-22 08:07:49 +00:00
|
|
|
module Utils where
|
|
|
|
|
|
|
|
import GHCup.OptParse as GHCup
|
|
|
|
import Options.Applicative
|
|
|
|
import Data.Bifunctor
|
2023-07-22 09:14:49 +00:00
|
|
|
import Data.Versions
|
|
|
|
import Data.List.NonEmpty (NonEmpty)
|
2023-07-22 08:07:49 +00:00
|
|
|
|
|
|
|
parseWith :: [String] -> IO Command
|
|
|
|
parseWith args =
|
|
|
|
optCommand <$> handleParseResult
|
|
|
|
(execParserPure defaultPrefs (info GHCup.opts fullDesc) args)
|
|
|
|
|
|
|
|
padLeft :: Int -> String -> String
|
|
|
|
padLeft desiredLength s = padding ++ s
|
|
|
|
where padding = replicate (desiredLength - length s) ' '
|
|
|
|
|
|
|
|
mapSecond :: (b -> c) -> [(a,b)] -> [(a,c)]
|
|
|
|
mapSecond = map . second
|
2023-07-22 09:14:49 +00:00
|
|
|
|
|
|
|
mkVersion :: NonEmpty VChunk -> Version
|
|
|
|
mkVersion chunks = Version Nothing chunks [] Nothing
|