cabal-add 0.2 → 0.2.0.1
raw patch · 5 files changed
+43/−31 lines, 5 filesdep ~Cabaldep ~Cabal-syntaxdep ~cabal-install-parsersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Cabal, Cabal-syntax, cabal-install-parsers, directory, process
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- app/Main.hs +17/−17
- cabal-add.cabal +8/−11
- src/Distribution/Client/Add.hs +12/−1
- tests/Main.hs +2/−2
CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.2.0.1++* Support `Cabal-3.18`.+ ## 0.2 * Allow add not only dependencies, but also modules.
app/Main.hs view
@@ -57,16 +57,16 @@ parseRawConfig :: Parser RawConfig parseRawConfig = do rcnfMProjectFile <-- optional $- strOption $- long "project-file"- <> metavar "FILE"- <> help "Set the path of the cabal.project file. Detect cabal.project or *.cabal in the current folder, if omitted."+ optional+ $ strOption+ $ long "project-file"+ <> metavar "FILE"+ <> help "Set the path of the cabal.project file. Detect cabal.project or *.cabal in the current folder, if omitted." rcnfArgs <-- some1 $- strArgument $- metavar "ARGS"- <> help "Optional package component (wildcards such as 'exe', 'test' or 'bench' are supported) to update, followed by a non-empty list of package(s) to add to 'build-depends' section. Version bounds can be provided as well, use quotes to escape comparisons from your shell. E. g., 'foo < 0.2'."+ some1+ $ strArgument+ $ metavar "ARGS"+ <> help "Optional package component (wildcards such as 'exe', 'test' or 'bench' are supported) to update, followed by a non-empty list of package(s) to add to 'build-depends' section. Version bounds can be provided as well, use quotes to escape comparisons from your shell. E. g., 'foo < 0.2'." pure RawConfig {..} resolveCabalProjectInCurrentFolder :: IO (Maybe FilePath)@@ -186,9 +186,9 @@ Nothing -> "No Cabal files or projects are found in the current folder, please specify --project-file." Just projFn -> "No Cabal files are found in " ++ projFn (errs, []) ->- Left $- L.intercalate "\n" $- map (\(fn, err) -> "Cannot add a dependency to " ++ fn ++ " because: " ++ err) errs+ Left+ $ L.intercalate "\n"+ $ map (\(fn, err) -> "Cannot add a dependency to " ++ fn ++ " because: " ++ err) errs (_, [inp]) -> pure $ snd inp (_, _inps) -> Left@@ -201,11 +201,11 @@ isCabalEnvVarSet <- isJust <$> lookupEnv "CABAL" rawArgs <- getArgs RawConfig {..} <-- withArgs ((if isCabalEnvVarSet then stripAdd else id) rawArgs) $- execParser $- info- (helper <*> parseRawConfig)- (fullDesc <> progDesc "Extend build-depends from the command line")+ withArgs ((if isCabalEnvVarSet then stripAdd else id) rawArgs)+ $ execParser+ $ info+ (helper <*> parseRawConfig)+ (fullDesc <> progDesc "Extend build-depends from the command line") cabalFiles <- resolveCabalFiles rcnfMProjectFile cabalFilesAndContent <-
cabal-add.cabal view
@@ -1,12 +1,13 @@ cabal-version: 3.0 name: cabal-add-version: 0.2+version: 0.2.0.1 license: BSD-3-Clause license-file: LICENSE maintainer: andrew.lelechenko@gmail.com author: Bodigrim tested-with:- ghc ==9.12.2 ghc ==9.10.2 ghc ==9.8.4 ghc ==9.6.7 ghc ==9.4.8+ ghc ==9.14.1 ghc ==9.12.2 ghc ==9.10.3 ghc ==9.8.4 ghc ==9.6.7+ ghc ==9.4.8 synopsis: Extend Cabal build-depends from the command line description:@@ -37,8 +38,8 @@ build-depends: base <5, bytestring <0.13,- Cabal >=3.8 && <3.15,- Cabal-syntax >=3.8 && <3.15,+ Cabal >=3.8 && <3.19,+ Cabal-syntax >=3.8 && <3.19, containers <0.9, mtl <2.4 @@ -51,12 +52,11 @@ base <5, bytestring <0.13, cabal-add,- cabal-install-parsers >=0.4.1 && <0.7,+ cabal-install-parsers >=0.4.1 && <0.8, Cabal-syntax, directory <1.4, filepath <1.6,- optparse-applicative >=0.16 && <0.20,- process <1.7+ optparse-applicative >=0.16 && <0.20 test-suite cabal-add-tests type: exitcode-stdio-1.0@@ -86,8 +86,5 @@ Cabal, cabal-add, Diff >=0.4,- directory,- process, string-qq,- tasty,- temporary+ tasty
src/Distribution/Client/Add.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}@@ -69,6 +70,10 @@ resolveBuildTargets, ) +#if MIN_VERSION_Cabal_syntax(3,17,0)+import Distribution.Fields (perror)+#endif+ -- | An input for 'executeAddConfig'. data AddConfig = AddConfig { cnfOrigContents :: !ByteString@@ -229,12 +234,18 @@ packDescr <- case snd $ runParseResult $ parseGenericPackageDescription contents of Left (_, err) ->- errorWithCtx $ L.unlines $ map (showPError fileName) $ NE.toList err+ errorWithCtx $ L.unlines $ map (showPError fileName . toPError) $ NE.toList err Right GenericPackageDescription {packageDescription = PackageDescription {specVersion = CabalSpecV1_0}} -> errorWithCtx legacyErr Right pd -> pure pd pure (fields, packDescr)+ where+#if MIN_VERSION_Cabal_syntax(3,17,0)+ toPError = perror+#else+ toPError = id+#endif readBuildTarget :: PackageDescription -> String -> Maybe ComponentName readBuildTarget pkg targetStr =
tests/Main.hs view
@@ -11,7 +11,7 @@ import Data.Char (isAlpha) import Data.Maybe (mapMaybe) import Data.String.QQ (s)-import System.Directory (findExecutable)+import System.Directory (findExecutable, makeAbsolute) import System.Exit (ExitCode (..)) import System.IO.Temp (withSystemTempDirectory) import System.Process (cwd, env, proc, readCreateProcessWithExitCode)@@ -29,7 +29,7 @@ instance IsTest CabalAddTest where testOptions = pure [] run _opts CabalAddTest {..} _yieldProgress = do- mCabalAddExe <- findExecutable "cabal-add"+ mCabalAddExe <- findExecutable "cabal-add" >>= traverse makeAbsolute case mCabalAddExe of Nothing -> pure $ testFailed "cabal-add executable is not in PATH" Just cabalAddExe -> do