Skip to content

Commit

Permalink
Merge pull request #8839 from ulysses4ever/t8835-init-config
Browse files Browse the repository at this point in the history
Allow no-comments, quiet, simple, minimal in init section of config
  • Loading branch information
mergify[bot] authored Mar 19, 2023
2 parents 6870def + f21e0a2 commit 85cac76
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cabal-install/src/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal user-config
Writing default configuration to <ROOT>/cabal.dist/cabal-config
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions changelog.d/issue-8835
Original file line number Diff line number Diff line change
@@ -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`

0 comments on commit 85cac76

Please sign in to comment.