Commit d1631633 authored by Oleg Grenrus's avatar Oleg Grenrus

Make ProjectFlags part of NixStyleFlags

This essentially makes -z/--ignore-project appear in all v2-commands
parent a4c0be01
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
-- | cabal-install CLI command: bench
--
......@@ -16,11 +16,12 @@ module Distribution.Client.CmdBench (
import Distribution.Client.ProjectOrchestration
import Distribution.Client.CmdErrorMessages
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags )
import qualified Distribution.Client.Setup as Client
import Distribution.Simple.Setup
( HaddockFlags, TestFlags, BenchmarkFlags, fromFlagOrDefault )
( GlobalFlags, ConfigFlags(..) )
import Distribution.Simple.Flag
( fromFlagOrDefault )
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
import Distribution.Pretty
......@@ -33,10 +34,8 @@ import Distribution.Simple.Utils
import Control.Monad (when)
benchCommand :: CommandUI ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags
)
benchCommand = Client.installCommand {
benchCommand :: CommandUI (NixStyleFlags ())
benchCommand = CommandUI {
commandName = "v2-bench",
commandSynopsis = "Run benchmarks",
commandUsage = usageAlternatives "v2-bench" [ "[TARGETS] [FLAGS]" ],
......@@ -65,6 +64,9 @@ benchCommand = Client.installCommand {
++ " Run the benchmark built with '-O2' (including local libs used)\n\n"
++ cmdCommonHelpTextNewBuildBeta
, commandDefaultFlags = defaultNixStyleFlags ()
, commandOptions = nixStyleOptions (const [])
}
......@@ -75,12 +77,8 @@ benchCommand = Client.installCommand {
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
benchAction :: ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags )
-> [String] -> GlobalFlags -> IO ()
benchAction ( configFlags, configExFlags, installFlags
, haddockFlags, testFlags, benchmarkFlags )
targetStrings globalFlags = do
benchAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
benchAction flags@NixStyleFlags {..} targetStrings globalFlags = do
baseCtx <- establishProjectBaseContext verbosity cliConfig OtherCommand
......@@ -119,11 +117,8 @@ benchAction ( configFlags, configExFlags, installFlags
runProjectPostBuildPhase verbosity baseCtx buildCtx buildOutcomes
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
-- | This defines what a 'TargetSelector' means for the @bench@ command.
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
......
{-# LANGUAGE RecordWildCards #-}
-- | cabal-install CLI command: build
--
module Distribution.Client.CmdBuild (
......@@ -17,13 +18,11 @@ import Distribution.Client.Compat.Prelude
import Distribution.Client.ProjectOrchestration
import Distribution.Client.CmdErrorMessages
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags
, liftOptions, yesNoOpt )
import qualified Distribution.Client.Setup as Client
import Distribution.Simple.Setup
( HaddockFlags, TestFlags, BenchmarkFlags
, Flag(..), toFlag, fromFlag, fromFlagOrDefault )
( GlobalFlags, ConfigFlags(..), yesNoOpt )
import Distribution.Simple.Flag ( Flag(..), toFlag, fromFlag, fromFlagOrDefault )
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives, option )
import Distribution.Verbosity
......@@ -34,11 +33,7 @@ import Distribution.Simple.Utils
import qualified Data.Map as Map
buildCommand ::
CommandUI
(BuildFlags, ( ConfigFlags, ConfigExFlags
, InstallFlags, HaddockFlags
, TestFlags, BenchmarkFlags ))
buildCommand :: CommandUI (NixStyleFlags BuildFlags)
buildCommand = CommandUI {
commandName = "v2-build",
commandSynopsis = "Compile targets within the project.",
......@@ -70,24 +65,16 @@ buildCommand = CommandUI {
++ " Build the component in profiling mode "
++ "(including dependencies as needed)\n\n"
++ cmdCommonHelpTextNewBuildBeta,
commandDefaultFlags =
(defaultBuildFlags, commandDefaultFlags Client.installCommand),
commandOptions = \ showOrParseArgs ->
liftOptions snd setSnd
(commandOptions Client.installCommand showOrParseArgs) ++
liftOptions fst setFst
[ option [] ["only-configure"]
"Instead of performing a full build just run the configure step"
buildOnlyConfigure (\v flags -> flags { buildOnlyConfigure = v })
(yesNoOpt showOrParseArgs)
]
++ cmdCommonHelpTextNewBuildBeta
, commandDefaultFlags = defaultNixStyleFlags defaultBuildFlags
, commandOptions = nixStyleOptions $ \showOrParseArgs ->
[ option [] ["only-configure"]
"Instead of performing a full build just run the configure step"
buildOnlyConfigure (\v flags -> flags { buildOnlyConfigure = v })
(yesNoOpt showOrParseArgs)
]
}
where
setFst a (_,b) = (a,b)
setSnd b (a,_) = (a,b)
data BuildFlags = BuildFlags
{ buildOnlyConfigure :: Flag Bool
}
......@@ -104,16 +91,8 @@ defaultBuildFlags = BuildFlags
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
buildAction ::
( BuildFlags
, ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags ))
-> [String] -> GlobalFlags -> IO ()
buildAction
( buildFlags
, ( configFlags, configExFlags, installFlags
, haddockFlags, testFlags, benchmarkFlags ))
targetStrings globalFlags = do
buildAction :: NixStyleFlags BuildFlags -> [String] -> GlobalFlags -> IO ()
buildAction flags@NixStyleFlags { extraFlags = buildFlags, ..} targetStrings globalFlags = do
-- TODO: This flags defaults business is ugly
let onlyConfigure = fromFlag (buildOnlyConfigure defaultBuildFlags
<> buildOnlyConfigure buildFlags)
......@@ -160,11 +139,8 @@ buildAction
runProjectPostBuildPhase verbosity baseCtx buildCtx buildOutcomes
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
-- | This defines what a 'TargetSelector' means for the @bench@ command.
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
......
{-# LANGUAGE RecordWildCards #-}
-- | cabal-install CLI command: configure
--
module Distribution.Client.CmdConfigure (
......@@ -13,10 +14,12 @@ import Distribution.Client.ProjectOrchestration
import Distribution.Client.ProjectConfig
( writeProjectLocalExtraConfig )
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags )
import Distribution.Simple.Setup
( HaddockFlags, TestFlags, BenchmarkFlags, fromFlagOrDefault )
( GlobalFlags, ConfigFlags(..) )
import Distribution.Simple.Flag
( fromFlagOrDefault )
import Distribution.Verbosity
( normal )
......@@ -24,12 +27,9 @@ import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
import Distribution.Simple.Utils
( wrapText, notice )
import qualified Distribution.Client.Setup as Client
configureCommand :: CommandUI ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags
)
configureCommand = Client.installCommand {
configureCommand :: CommandUI (NixStyleFlags ())
configureCommand = CommandUI {
commandName = "v2-configure",
commandSynopsis = "Add extra project configuration",
commandUsage = usageAlternatives "v2-configure" [ "[FLAGS]" ],
......@@ -67,7 +67,9 @@ configureCommand = Client.installCommand {
++ " project configuration works.\n\n"
++ cmdCommonHelpTextNewBuildBeta
}
, commandDefaultFlags = defaultNixStyleFlags ()
, commandOptions = nixStyleOptions (const [])
}
-- | To a first approximation, the @configure@ just runs the first phase of
-- the @build@ command where we bring the install plan up to date (thus
......@@ -79,12 +81,8 @@ configureCommand = Client.installCommand {
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
configureAction :: ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags )
-> [String] -> GlobalFlags -> IO ()
configureAction ( configFlags, configExFlags, installFlags
, haddockFlags, testFlags, benchmarkFlags )
_extraArgs globalFlags = do
configureAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
configureAction flags@NixStyleFlags {..} _extraArgs globalFlags = do
--TODO: deal with _extraArgs, since flags with wrong syntax end up there
baseCtx <- establishProjectBaseContext verbosity cliConfig OtherCommand
......@@ -122,9 +120,6 @@ configureAction ( configFlags, configExFlags, installFlags
printPlan verbosity baseCtx' buildCtx
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
......@@ -21,13 +21,12 @@ import Distribution.Client.InstallPlan
( GenericPlanPackage(..)
, toGraph
)
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.Setup
( ConfigExFlags
, ConfigFlags(configVerbosity)
( ConfigFlags(configVerbosity)
, GlobalFlags
, InstallFlags
)
import qualified Distribution.Client.Setup as Client
import Distribution.Client.ProjectOrchestration
( ProjectBuildContext(..)
, runProjectPreBuildPhase
......@@ -73,11 +72,8 @@ import Distribution.Simple.Program.Types
import Distribution.Simple.GHC
( getImplInfo
, GhcImplInfo(supportsPkgEnvFiles) )
import Distribution.Simple.Setup
( HaddockFlags
, TestFlags
, BenchmarkFlags
, fromFlagOrDefault
import Distribution.Simple.Flag
( fromFlagOrDefault
)
import Distribution.Simple.Utils
( die'
......@@ -97,9 +93,7 @@ import Distribution.Client.Compat.Prelude
import qualified Data.Set as S
import qualified Data.Map as M
execCommand :: CommandUI ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags
)
execCommand :: CommandUI (NixStyleFlags ())
execCommand = CommandUI
{ commandName = "v2-exec"
, commandSynopsis = "Give a command access to the store."
......@@ -120,16 +114,12 @@ execCommand = CommandUI
++ " to choose an appropriate version of ghc and to include any"
++ " ghc-specific flags requested."
, commandNotes = Nothing
, commandOptions = commandOptions Client.installCommand
, commandDefaultFlags = commandDefaultFlags Client.installCommand
, commandOptions = nixStyleOptions (const [])
, commandDefaultFlags = defaultNixStyleFlags ()
}
execAction :: ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags )
-> [String] -> GlobalFlags -> IO ()
execAction ( configFlags, configExFlags, installFlags
, haddockFlags, testFlags, benchmarkFlags )
extraArgs globalFlags = do
execAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
execAction flags@NixStyleFlags {..} extraArgs globalFlags = do
baseCtx <- establishProjectBaseContext verbosity cliConfig OtherCommand
......@@ -198,11 +188,8 @@ execAction ( configFlags, configExFlags, installFlags
runProgramInvocation verbosity invocation
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
withOverrides env args program = program
{ programOverrideEnv = programOverrideEnv program ++ env
, programDefaultArgs = programDefaultArgs program ++ args}
......
......@@ -7,6 +7,8 @@ module Distribution.Client.CmdFreeze (
freezeAction,
) where
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.ProjectOrchestration
import Distribution.Client.ProjectPlanning
import Distribution.Client.ProjectConfig
......@@ -32,9 +34,9 @@ import Distribution.Version
import Distribution.PackageDescription
( FlagAssignment, nullFlagAssignment )
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags )
import Distribution.Simple.Setup
( HaddockFlags, TestFlags, BenchmarkFlags, fromFlagOrDefault )
( GlobalFlags, ConfigFlags(..) )
import Distribution.Simple.Flag
( fromFlagOrDefault )
import Distribution.Simple.Flag (Flag (..))
import Distribution.Simple.Utils
( die', notice, wrapText )
......@@ -47,13 +49,9 @@ import Control.Monad (unless)
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
import qualified Distribution.Client.Setup as Client
freezeCommand :: CommandUI ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags
)
freezeCommand = Client.installCommand {
freezeCommand :: CommandUI (NixStyleFlags ())
freezeCommand = CommandUI {
commandName = "v2-freeze",
commandSynopsis = "Freeze dependencies.",
commandUsage = usageAlternatives "v2-freeze" [ "[FLAGS]" ],
......@@ -93,6 +91,8 @@ freezeCommand = Client.installCommand {
++ "https://github.com/haskell/cabal/issues and if you\nhave any time "
++ "to get involved and help with testing, fixing bugs etc then\nthat "
++ "is very much appreciated.\n"
, commandDefaultFlags = defaultNixStyleFlags ()
, commandOptions = nixStyleOptions (const [])
}
-- | To a first approximation, the @freeze@ command runs the first phase of
......@@ -102,12 +102,8 @@ freezeCommand = Client.installCommand {
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
freezeAction :: ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags )
-> [String] -> GlobalFlags -> IO ()
freezeAction ( configFlags, configExFlags, installFlags
, haddockFlags, testFlags, benchmarkFlags )
extraArgs globalFlags = do
freezeAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
freezeAction flags@NixStyleFlags {..} extraArgs globalFlags = do
unless (null extraArgs) $
die' verbosity $ "'freeze' doesn't take any extra arguments: "
......@@ -133,11 +129,8 @@ freezeAction ( configFlags, configExFlags, installFlags
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
......
......@@ -72,7 +72,7 @@ haddockCommand = CommandUI {
-- "Distribution.Client.ProjectOrchestration"
--
haddockAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
haddockAction NixStyleFlags {..} targetStrings globalFlags = do
haddockAction flags@NixStyleFlags {..} targetStrings globalFlags = do
baseCtx <- establishProjectBaseContext verbosity cliConfig HaddockCommand
targetSelectors <- either (reportTargetSelectorProblems verbosity) return
......@@ -108,11 +108,7 @@ haddockAction NixStyleFlags {..} targetStrings globalFlags = do
runProjectPostBuildPhase verbosity baseCtx buildCtx buildOutcomes
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags mempty -- ClientInstallFlags, not needed here
-- | This defines what a 'TargetSelector' means for the @haddock@ command.
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
......
......@@ -48,6 +48,7 @@ import Distribution.Client.ProjectConfig
)
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.ProjectFlags (ProjectFlags (..))
import Distribution.Client.ProjectConfig.Types
( ProjectConfig(..), ProjectConfigShared(..)
, ProjectConfigBuildOnly(..), PackageConfig(..)
......@@ -198,7 +199,7 @@ installCommand = CommandUI
-- "Distribution.Client.ProjectOrchestration"
--
installAction :: NixStyleFlags ClientInstallFlags -> [String] -> GlobalFlags -> IO ()
installAction NixStyleFlags { extraFlags = clientInstallFlags', .. } targetStrings globalFlags = do
installAction flags@NixStyleFlags { extraFlags = clientInstallFlags', .. } targetStrings globalFlags = do
-- Ensure there were no invalid configuration options specified.
verifyPreconditionsOrDie verbosity configFlags'
......@@ -305,7 +306,7 @@ installAction NixStyleFlags { extraFlags = clientInstallFlags', .. } targetStrin
return (packageSpecifiers, uris, packageTargets, projectConfig)
let
ignoreProject = fromFlagOrDefault False (cinstIgnoreProject clientInstallFlags)
ignoreProject = fromFlagOrDefault False (flagIgnoreProject projectFlags)
(specs, uris, targetSelectors, config) <-
withProjectOrGlobalConfigIgn ignoreProject verbosity globalConfigFlag withProject withoutProject
......@@ -404,9 +405,9 @@ installAction NixStyleFlags { extraFlags = clientInstallFlags', .. } targetStrin
configFlags' = disableTestsBenchsByDefault configFlags
verbosity = fromFlagOrDefault normal (configVerbosity configFlags')
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags' configExFlags
installFlags clientInstallFlags'
haddockFlags testFlags benchmarkFlags
globalFlags
flags { configFlags = configFlags' }
clientInstallFlags'
globalConfigFlag = projectConfigConfigFile (projectConfigShared cliConfig)
-- | Verify that invalid config options were not passed to the install command.
......
......@@ -29,7 +29,6 @@ instance Structured InstallMethod
data ClientInstallFlags = ClientInstallFlags
{ cinstInstallLibs :: Flag Bool
, cinstIgnoreProject :: Flag Bool
, cinstEnvironmentPath :: Flag FilePath
, cinstOverwritePolicy :: Flag OverwritePolicy
, cinstInstallMethod :: Flag InstallMethod
......@@ -49,7 +48,6 @@ instance Structured ClientInstallFlags
defaultClientInstallFlags :: ClientInstallFlags
defaultClientInstallFlags = ClientInstallFlags
{ cinstInstallLibs = toFlag False
, cinstIgnoreProject = toFlag False
, cinstEnvironmentPath = mempty
, cinstOverwritePolicy = mempty
, cinstInstallMethod = mempty
......@@ -62,10 +60,6 @@ clientInstallOptions _ =
"Install libraries rather than executables from the target package."
cinstInstallLibs (\v flags -> flags { cinstInstallLibs = v })
trueArg
, option "z" ["ignore-project"]
"Ignore local project configuration"
cinstIgnoreProject (\v flags -> flags { cinstIgnoreProject = v })
trueArg
, option [] ["package-env", "env"]
"Set the environment file that may be modified."
cinstEnvironmentPath (\pf flags -> flags { cinstEnvironmentPath = pf })
......
......@@ -197,7 +197,7 @@ replCommand = Client.installCommand {
-- "Distribution.Client.ProjectOrchestration"
--
replAction :: NixStyleFlags (ReplFlags, EnvFlags) -> [String] -> GlobalFlags -> IO ()
replAction NixStyleFlags { extraFlags = (replFlags, envFlags), ..} targetStrings globalFlags = do
replAction flags@NixStyleFlags { extraFlags = (replFlags, envFlags), ..} targetStrings globalFlags = do
let
ignoreProject = fromFlagOrDefault False (envIgnoreProject envFlags)
with = withProject cliConfig verbosity targetStrings
......@@ -296,11 +296,7 @@ replAction NixStyleFlags { extraFlags = (replFlags, envFlags), ..} targetStrings
finalizer
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags mempty -- ClientInstallFlags, not needed here
globalConfigFlag = projectConfigConfigFile (projectConfigShared cliConfig)
validatedTargets elaboratedPlan targetSelectors = do
......
......@@ -154,7 +154,7 @@ runCommand = CommandUI
-- "Distribution.Client.ProjectOrchestration"
--
runAction :: NixStyleFlags ClientRunFlags -> [String] -> GlobalFlags -> IO ()
runAction NixStyleFlags {extraFlags=clientRunFlags, ..} targetStrings globalFlags = do
runAction flags@NixStyleFlags {extraFlags=clientRunFlags, ..} targetStrings globalFlags = do
globalTmp <- getTemporaryDirectory
tmpDir <- createTempDirectory globalTmp "cabal-repl."
......@@ -297,11 +297,7 @@ runAction NixStyleFlags {extraFlags=clientRunFlags, ..} targetStrings globalFlag
handleDoesNotExist () (removeDirectoryRecursive tmpDir)
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags
mempty -- ClientInstallFlags, not needed here
haddockFlags testFlags benchmarkFlags
cliConfig = commandLineFlagsToProjectConfig globalFlags flags mempty -- ClientInstallFlags, not needed here
globalConfigFlag = projectConfigConfigFile (projectConfigShared cliConfig)
-- | Used by the main CLI parser as heuristic to decide whether @cabal@ was
......
......@@ -15,11 +15,13 @@ import Distribution.Client.CmdErrorMessages
( Plural(..), renderComponentKind )
import Distribution.Client.ProjectOrchestration
( ProjectBaseContext(..), CurrentCommand(..), establishProjectBaseContext, establishProjectBaseContextWithRoot)
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), defaultNixStyleFlags )
import Distribution.Client.TargetSelector
( TargetSelector(..), ComponentKind
, readTargetSelectors, reportTargetSelectorProblems )
import Distribution.Client.Setup
( GlobalFlags(..), InstallFlags (installProjectFileName) )
( GlobalFlags(..) )
import Distribution.Solver.Types.SourcePackage
( SourcePackage(..) )
import Distribution.Client.Types
......@@ -96,7 +98,7 @@ sdistCommand = CommandUI
, commandNotes = Nothing
, commandDefaultFlags = (defaultProjectFlags, defaultSdistFlags)
, commandOptions = \showOrParseArgs ->
map (liftOptionL _1) projectFlagsOptions ++
map (liftOptionL _1) (projectFlagsOptions showOrParseArgs) ++
map (liftOptionL _2) (sdistOptions showOrParseArgs)
}
......@@ -202,12 +204,12 @@ sdistAction (ProjectFlags{..}, SdistFlags{..}) targetStrings globalFlags = do
prjConfig :: ProjectConfig
prjConfig = commandLineFlagsToProjectConfig
globalFlags
mempty { configVerbosity = sdistVerbosity, configDistPref = sdistDistDir }
mempty
mempty { installProjectFileName = flagProjectFileName }
mempty
mempty
mempty
(defaultNixStyleFlags ())
{ configFlags = (configFlags $ defaultNixStyleFlags ())
{ configVerbosity = sdistVerbosity
, configDistPref = sdistDistDir
}
}
mempty
globalConfigFlag = projectConfigConfigFile (projectConfigShared prjConfig)
......
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
-- | cabal-install CLI command: test
--
......@@ -16,11 +16,12 @@ module Distribution.Client.CmdTest (
import Distribution.Client.ProjectOrchestration
import Distribution.Client.CmdErrorMessages
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.Setup
( GlobalFlags(..), ConfigFlags(..), ConfigExFlags, InstallFlags )
import qualified Distribution.Client.Setup as Client
( GlobalFlags(..), ConfigFlags(..) )
import Distribution.Simple.Setup
( HaddockFlags, TestFlags(..), BenchmarkFlags(..), fromFlagOrDefault )
( TestFlags(..), fromFlagOrDefault )
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
import Distribution.Simple.Flag
......@@ -36,10 +37,8 @@ import Control.Monad (when)
import qualified System.Exit (exitSuccess)
testCommand :: CommandUI ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags
)
testCommand = Client.installCommand
testCommand :: CommandUI (NixStyleFlags ())
testCommand = CommandUI
{ commandName = "v2-test"
, commandSynopsis = "Run test-suites"
, commandUsage = usageAlternatives "v2-test" [ "[TARGETS] [FLAGS]" ]
......@@ -72,6 +71,8 @@ testCommand = Client.installCommand
++ cmdCommonHelpTextNewBuildBeta
, commandDefaultFlags = defaultNixStyleFlags ()
, commandOptions = nixStyleOptions (const [])
}
......@@ -86,12 +87,8 @@ testCommand = Client.installCommand
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
testAction :: ( ConfigFlags, ConfigExFlags, InstallFlags
, HaddockFlags, TestFlags, BenchmarkFlags )
-> [String] -> GlobalFlags -> IO ()
testAction ( configFlags, configExFlags, installFlags
, haddockFlags, testFlags, benchmarkFlags )
targetStrings globalFlags = do
testAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
testAction flags@NixStyleFlags {..} targetStrings globalFlags = do
baseCtx <- establishProjectBaseContext verbosity cliConfig OtherCommand
......@@ -131,11 +128,7 @@ testAction ( configFlags, configExFlags, installFlags
where
failWhenNoTestSuites = testFailWhenNoTestSuites testFlags
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags