diff --git a/cabal-install/src/Distribution/Client/Config.hs b/cabal-install/src/Distribution/Client/Config.hs index 33793657282..cea5e56f407 100644 --- a/cabal-install/src/Distribution/Client/Config.hs +++ b/cabal-install/src/Distribution/Client/Config.hs @@ -922,7 +922,11 @@ commentSavedConfig = do IT.language = toFlag Haskell2010, IT.license = NoFlag, IT.sourceDirs = Flag [IT.defaultSourceDir], - IT.applicationDirs = Flag [IT.defaultApplicationDir] + IT.applicationDirs = Flag [IT.defaultApplicationDir], + IT.quiet = Flag False, + IT.noComments = Flag False, + IT.minimal = Flag False, + IT.simpleProject = Flag False }, savedInstallFlags = defaultInstallFlags, savedClientInstallFlags= defaultClientInstallFlags, @@ -1462,10 +1466,10 @@ initFlagsFields = [ field , name `notElem` exclusions ] where exclusions = - [ "author", "email", "quiet", "no-comments", "minimal", "overwrite" + [ "author", "email", "overwrite" , "package-dir", "packagedir", "package-name", "version", "homepage" , "synopsis", "category", "extra-source-file", "lib", "exe", "libandexe" - , "simple", "main-is", "expose-module", "exposed-modules", "extension" + , "main-is", "expose-module", "exposed-modules", "extension" , "dependency", "build-tool", "with-compiler" , "verbose" ] diff --git a/cabal-testsuite/PackageTests/ConfigFile/InitSectionFields/cabal.out b/cabal-testsuite/PackageTests/ConfigFile/InitSectionFields/cabal.out new file mode 100644 index 00000000000..e3dc6d7eee9 --- /dev/null +++ b/cabal-testsuite/PackageTests/ConfigFile/InitSectionFields/cabal.out @@ -0,0 +1,2 @@ +# cabal user-config +Writing default configuration to /cabal.dist/cabal-config diff --git a/cabal-testsuite/PackageTests/ConfigFile/InitSectionFields/cabal.test.hs b/cabal-testsuite/PackageTests/ConfigFile/InitSectionFields/cabal.test.hs new file mode 100644 index 00000000000..ac7c93345f7 --- /dev/null +++ b/cabal-testsuite/PackageTests/ConfigFile/InitSectionFields/cabal.test.hs @@ -0,0 +1,21 @@ +import Test.Cabal.Prelude +import Data.List ( isInfixOf, groupBy ) +import Data.Function ( on ) + +main = cabalTest $ do + workdir <- fmap testWorkDir getTestEnv + let conf = workdir "cabal-config" + cabalG ["--config-file", conf] "user-config" ["init"] + confContents <- liftIO $ readFile conf + let ls = lines confContents + sections = groupBy ((==) `on` (== "")) ls + [initLs] = filter ((== "init") . head) sections + init = unlines initLs + assertInitSectionContainsField init "quiet" + assertInitSectionContainsField init "no-comments" + assertInitSectionContainsField init "minimal" + assertInitSectionContainsField init "simple" + +assertInitSectionContainsField section field = + assertBool ("init section of config should contain the field " ++ field) + ((field ++ ":") `isInfixOf` section) diff --git a/changelog.d/issue-8835 b/changelog.d/issue-8835 new file mode 100644 index 00000000000..587d4e34984 --- /dev/null +++ b/changelog.d/issue-8835 @@ -0,0 +1,6 @@ +synopsis: config file: allow more flags in the init section +packages: cabal-install +prs: #8839 +issues: #8835 +description: The init section of config file now allows the following fields: +`no-comments`, `quiet`, `simple` and `minimal`