Skip to content

Commit

Permalink
Make the configure command take the defaults from the config file
Browse files Browse the repository at this point in the history
Just like the install command has always done. This makes them consistent.
So by default that means cabal configure uses --user --prefix=$HOME/.cabal
  • Loading branch information
dcoutts committed Jan 19, 2008
1 parent af635b9 commit eded057
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Hackage/Setup.hs
Expand Up @@ -12,6 +12,7 @@
-----------------------------------------------------------------------------
module Hackage.Setup
( globalCommand, Cabal.GlobalFlags(..)
, configureCommand
, installCommand --Cabal.InstallFlags(..)
, listCommand
, updateCommand
Expand Down Expand Up @@ -61,6 +62,11 @@ globalCommand = Cabal.globalCommand {
++ "\nSee http://www.haskell.org/cabal/ for more information.\n"
}

configureCommand :: CommandUI Cabal.ConfigFlags
configureCommand = (Cabal.configureCommand defaultProgramConfiguration) {
commandDefaultFlags = mempty
}

installCommand :: CommandUI Cabal.ConfigFlags
installCommand = (Cabal.configureCommand defaultProgramConfiguration) {
commandName = "install",
Expand Down
15 changes: 13 additions & 2 deletions Main.hs
Expand Up @@ -78,15 +78,15 @@ mainWorker args =
++ " of the Cabal library "

commands =
[installCommand `commandAddAction` installAction
[configureCommand `commandAddAction` configureAction
,installCommand `commandAddAction` installAction
,infoCommand `commandAddAction` infoAction
,listCommand `commandAddAction` listAction
,updateCommand `commandAddAction` updateAction
,upgradeCommand `commandAddAction` upgradeAction
,fetchCommand `commandAddAction` fetchAction
,uploadCommand `commandAddAction` uploadAction

,wrapperAction (Cabal.configureCommand defaultProgramConfiguration)
,wrapperAction (Cabal.buildCommand defaultProgramConfiguration)
,wrapperAction Cabal.copyCommand
,wrapperAction Cabal.haddockCommand
Expand All @@ -106,6 +106,17 @@ wrapperAction command =
let args = commandName command : commandShowOptions command flags ++ extraArgs
in setupWrapper args Nothing

configureAction :: Cabal.ConfigFlags -> [String] -> IO ()
configureAction flags extraArgs = do
configFile <- defaultConfigFile --FIXME
let verbosity = fromFlagOrDefault normal (Cabal.configVerbose flags)
config <- loadConfig verbosity configFile
let flags' = savedConfigToConfigFlags (Cabal.configPackageDB flags) config
`mappend` flags
args = commandName configureCommand
: commandShowOptions configureCommand flags' ++ extraArgs
setupWrapper args Nothing

installAction :: Cabal.ConfigFlags -> [String] -> IO ()
installAction flags extraArgs = do
pkgs <- either die return (parsePackageArgs extraArgs)
Expand Down

0 comments on commit eded057

Please sign in to comment.