Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow no-comments, quiet, simple, minimal in init section of config #8839

Merged
merged 1 commit into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`