Commit e29406c2 authored by Matt Renaud's avatar Matt Renaud

Add global configuration option for non-interactive cabal init.

parent 5a1ca1fd
......@@ -53,9 +53,12 @@ import Distribution.Client.Types
)
import Distribution.Client.BuildReports.Types
( ReportLevel(..) )
import qualified Distribution.Client.Init.Types as IT
( InitFlags(..) )
import Distribution.Client.Setup
( GlobalFlags(..), globalCommand, defaultGlobalFlags
, ConfigExFlags(..), configureExOptions, defaultConfigExFlags
, initOptions
, InstallFlags(..), installOptions, defaultInstallFlags
, UploadFlags(..), uploadCommand
, ReportFlags(..), reportCommand
......@@ -147,6 +150,7 @@ import GHC.Generics ( Generic )
data SavedConfig = SavedConfig {
savedGlobalFlags :: GlobalFlags,
savedInitFlags :: IT.InitFlags,
savedInstallFlags :: InstallFlags,
savedConfigureFlags :: ConfigFlags,
savedConfigureExFlags :: ConfigExFlags,
......@@ -165,6 +169,7 @@ instance Monoid SavedConfig where
instance Semigroup SavedConfig where
a <> b = SavedConfig {
savedGlobalFlags = combinedSavedGlobalFlags,
savedInitFlags = combinedSavedInitFlags,
savedInstallFlags = combinedSavedInstallFlags,
savedConfigureFlags = combinedSavedConfigureFlags,
savedConfigureExFlags = combinedSavedConfigureExFlags,
......@@ -246,6 +251,39 @@ instance Semigroup SavedConfig where
combine = combine' savedGlobalFlags
lastNonEmptyNL = lastNonEmptyNL' savedGlobalFlags
combinedSavedInitFlags = IT.InitFlags {
IT.nonInteractive = combine IT.nonInteractive,
IT.quiet = combine IT.quiet,
IT.packageDir = combine IT.packageDir,
IT.noComments = combine IT.noComments,
IT.minimal = combine IT.minimal,
IT.simpleProject = combine IT.simpleProject,
IT.packageName = combine IT.packageName,
IT.version = combine IT.version,
IT.cabalVersion = combine IT.cabalVersion,
IT.license = combine IT.license,
IT.author = combine IT.author,
IT.email = combine IT.email,
IT.homepage = combine IT.homepage,
IT.synopsis = combine IT.synopsis,
IT.category = combine IT.category,
IT.extraSrc = combineMonoid savedInitFlags IT.extraSrc,
IT.packageType = combine IT.packageType,
IT.mainIs = combine IT.mainIs,
IT.language = combine IT.language,
IT.exposedModules = combineMonoid savedInitFlags IT.exposedModules,
IT.otherModules = combineMonoid savedInitFlags IT.otherModules,
IT.otherExts = combineMonoid savedInitFlags IT.otherExts,
IT.dependencies = combineMonoid savedInitFlags IT.dependencies,
IT.sourceDirs = combineMonoid savedInitFlags IT.sourceDirs,
IT.buildTools = combineMonoid savedInitFlags IT.buildTools,
IT.initHcPath = combine IT.initHcPath,
IT.initVerbosity = combine IT.initVerbosity,
IT.overwrite = combine IT.overwrite
}
where
combine = combine' savedInitFlags
combinedSavedInstallFlags = InstallFlags {
installDocumentation = combine installDocumentation,
installHaddockIndex = combine installHaddockIndex,
......@@ -754,6 +792,9 @@ commentSavedConfig = do
savedGlobalFlags = defaultGlobalFlags {
globalRemoteRepos = toNubList [defaultRemoteRepo]
},
savedInitFlags = mempty {
IT.nonInteractive = toFlag False
},
savedInstallFlags = defaultInstallFlags,
savedConfigureExFlags = defaultConfigExFlags {
configAllowNewer = Just (AllowNewer mempty),
......@@ -873,6 +914,15 @@ configFieldDescriptions src =
configAllowNewer (\v flags -> flags { configAllowNewer = v })
]
++ toSavedConfig liftInitFlag
(initOptions ParseArgs)
["quiet", "no-comments", "minimal", "overwrite", "package-dir",
"packagedir", "package-name", "version", "cabal-version", "license",
"author", "email", "homepage", "synopsis", "category",
"extra-source-file", "lib", "exe", "libandexe", "simple",
"main-is", "language", "exposed-module", "extension", "dependency",
"source-dir", "build-tool", "with-compiler"] []
++ toSavedConfig liftInstallFlag
(installOptions ParseArgs)
["dry-run", "only", "only-dependencies", "dependencies-only"] []
......@@ -980,6 +1030,10 @@ liftConfigExFlag :: FieldDescr ConfigExFlags -> FieldDescr SavedConfig
liftConfigExFlag = liftField
savedConfigureExFlags (\flags conf -> conf { savedConfigureExFlags = flags })
liftInitFlag :: FieldDescr IT.InitFlags -> FieldDescr SavedConfig
liftInitFlag = liftField
savedInitFlags (\flags conf -> conf { savedInitFlags = flags })
liftInstallFlag :: FieldDescr InstallFlags -> FieldDescr SavedConfig
liftInstallFlag = liftField
savedInstallFlags (\flags conf -> conf { savedInstallFlags = flags })
......
This diff is collapsed.
......@@ -1141,6 +1141,7 @@ initAction initFlags extraArgs globalFlags = do
let configFlags = savedConfigureFlags config `mappend`
-- override with `--with-compiler` from CLI if available
mempty { configHcPath = initHcPath initFlags }
let initFlags' = savedInitFlags config `mappend` initFlags
let globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, _, progdb) <- configCompilerAux' configFlags
withRepoContext verbosity globalFlags' $ \repoContext ->
......@@ -1149,7 +1150,7 @@ initAction initFlags extraArgs globalFlags = do
repoContext
comp
progdb
initFlags
initFlags'
sandboxAction :: SandboxFlags -> [String] -> Action
sandboxAction sandboxFlags extraArgs globalFlags = do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment