@@ -23,15 +23,20 @@ import Distribution.Client.Compat.Prelude hiding (toList)
23
23
import Distribution.Client.ProjectOrchestration
24
24
import Distribution.Client.CmdErrorMessages
25
25
26
+ import Distribution.Client.CmdRun.ClientRunFlags
27
+
26
28
import Distribution.Client.Setup
27
- ( GlobalFlags (.. ), ConfigFlags (.. ), ConfigExFlags , InstallFlags )
29
+ ( GlobalFlags (.. ), ConfigFlags (.. ), ConfigExFlags , InstallFlags (.. )
30
+ , configureExOptions , haddockOptions , installOptions , testOptions
31
+ , benchmarkOptions , configureOptions , liftOptions )
32
+ import Distribution.Solver.Types.ConstraintSource
33
+ ( ConstraintSource (.. ) )
28
34
import Distribution.Client.GlobalFlags
29
35
( defaultGlobalFlags )
30
- import qualified Distribution.Client.Setup as Client
31
36
import Distribution.Simple.Setup
32
37
( HaddockFlags , TestFlags , BenchmarkFlags , fromFlagOrDefault )
33
38
import Distribution.Simple.Command
34
- ( CommandUI (.. ), usageAlternatives )
39
+ ( CommandUI (.. ), OptionField ( .. ), usageAlternatives )
35
40
import Distribution.Types.ComponentName
36
41
( showComponentName )
37
42
import Distribution.Deprecated.Text
@@ -45,7 +50,7 @@ import Distribution.Client.CmdInstall
45
50
( establishDummyProjectBaseContext )
46
51
import Distribution.Client.ProjectConfig
47
52
( ProjectConfig (.. ), ProjectConfigShared (.. )
48
- , withProjectOrGlobalConfig )
53
+ , withProjectOrGlobalConfigIgn )
49
54
import Distribution.Client.ProjectPlanning
50
55
( ElaboratedConfiguredPackage (.. )
51
56
, ElaboratedInstallPlan , binDirectoryFor )
@@ -109,43 +114,74 @@ import System.FilePath
109
114
110
115
runCommand :: CommandUI ( ConfigFlags , ConfigExFlags , InstallFlags
111
116
, HaddockFlags , TestFlags , BenchmarkFlags
117
+ , ClientRunFlags
112
118
)
113
- runCommand = Client. installCommand {
114
- commandName = " v2-run" ,
115
- commandSynopsis = " Run an executable." ,
116
- commandUsage = usageAlternatives " v2-run"
117
- [ " [TARGET] [FLAGS] [-- EXECUTABLE_FLAGS]" ],
118
- commandDescription = Just $ \ pname -> wrapText $
119
- " Runs the specified executable-like component (an executable, a test, "
120
- ++ " or a benchmark), first ensuring it is up to date.\n\n "
121
-
122
- ++ " Any executable-like component in any package in the project can be "
123
- ++ " specified. A package can be specified if contains just one "
124
- ++ " executable-like. The default is to use the package in the current "
125
- ++ " directory if it contains just one executable-like.\n\n "
126
-
127
- ++ " Extra arguments can be passed to the program, but use '--' to "
128
- ++ " separate arguments for the program from arguments for " ++ pname
129
- ++ " . The executable is run in an environment where it can find its "
130
- ++ " data files inplace in the build tree.\n\n "
131
-
132
- ++ " Dependencies are built or rebuilt as necessary. Additional "
133
- ++ " configuration flags can be specified on the command line and these "
134
- ++ " extend the project configuration from the 'cabal.project', "
135
- ++ " 'cabal.project.local' and other files." ,
136
- commandNotes = Just $ \ pname ->
137
- " Examples:\n "
138
- ++ " " ++ pname ++ " v2-run\n "
139
- ++ " Run the executable-like in the package in the current directory\n "
140
- ++ " " ++ pname ++ " v2-run foo-tool\n "
141
- ++ " Run the named executable-like (in any package in the project)\n "
142
- ++ " " ++ pname ++ " v2-run pkgfoo:foo-tool\n "
143
- ++ " Run the executable-like 'foo-tool' in the package 'pkgfoo'\n "
144
- ++ " " ++ pname ++ " v2-run foo -O2 -- dothing --fooflag\n "
145
- ++ " Build with '-O2' and run the program, passing it extra arguments.\n\n "
146
-
147
- ++ cmdCommonHelpTextNewBuildBeta
119
+ runCommand = CommandUI
120
+ { commandName = " v2-run"
121
+ , commandSynopsis = " Run an executable."
122
+ , commandUsage = usageAlternatives " v2-run"
123
+ [ " [TARGET] [FLAGS] [-- EXECUTABLE_FLAGS]" ]
124
+ , commandDescription = Just $ \ pname -> wrapText $
125
+ " Runs the specified executable-like component (an executable, a test, "
126
+ ++ " or a benchmark), first ensuring it is up to date.\n\n "
127
+
128
+ ++ " Any executable-like component in any package in the project can be "
129
+ ++ " specified. A package can be specified if contains just one "
130
+ ++ " executable-like. The default is to use the package in the current "
131
+ ++ " directory if it contains just one executable-like.\n\n "
132
+
133
+ ++ " Extra arguments can be passed to the program, but use '--' to "
134
+ ++ " separate arguments for the program from arguments for " ++ pname
135
+ ++ " . The executable is run in an environment where it can find its "
136
+ ++ " data files inplace in the build tree.\n\n "
137
+
138
+ ++ " Dependencies are built or rebuilt as necessary. Additional "
139
+ ++ " configuration flags can be specified on the command line and these "
140
+ ++ " extend the project configuration from the 'cabal.project', "
141
+ ++ " 'cabal.project.local' and other files."
142
+ , commandNotes = Just $ \ pname ->
143
+ " Examples:\n "
144
+ ++ " " ++ pname ++ " v2-run\n "
145
+ ++ " Run the executable-like in the package in the current directory\n "
146
+ ++ " " ++ pname ++ " v2-run foo-tool\n "
147
+ ++ " Run the named executable-like (in any package in the project)\n "
148
+ ++ " " ++ pname ++ " v2-run pkgfoo:foo-tool\n "
149
+ ++ " Run the executable-like 'foo-tool' in the package 'pkgfoo'\n "
150
+ ++ " " ++ pname ++ " v2-run foo -O2 -- dothing --fooflag\n "
151
+ ++ " Build with '-O2' and run the program, passing it extra arguments.\n\n "
152
+
153
+ ++ cmdCommonHelpTextNewBuildBeta
154
+ , commandDefaultFlags = (mempty , mempty , mempty , mempty , mempty , mempty , mempty )
155
+ , commandOptions = \ showOrParseArgs ->
156
+ liftOptions get1 set1
157
+ -- Note: [Hidden Flags]
158
+ -- hide "constraint", "dependency", and
159
+ -- "exact-configuration" from the configure options.
160
+ (filter ((`notElem` [" constraint" , " dependency"
161
+ , " exact-configuration" ])
162
+ . optionName) $
163
+ configureOptions showOrParseArgs)
164
+ ++ liftOptions get2 set2 (configureExOptions showOrParseArgs ConstraintSourceCommandlineFlag )
165
+ ++ liftOptions get3 set3
166
+ -- hide "target-package-db" flag from the
167
+ -- install options.
168
+ (filter ((`notElem` [" target-package-db" ])
169
+ . optionName) $
170
+ installOptions showOrParseArgs)
171
+ ++ liftOptions get4 set4 (haddockOptions showOrParseArgs)
172
+ ++ liftOptions get5 set5 (testOptions showOrParseArgs)
173
+ ++ liftOptions get6 set6 (benchmarkOptions showOrParseArgs)
174
+ ++ liftOptions get7 set7 (clientRunOptions showOrParseArgs)
148
175
}
176
+ where
177
+ get1 (a,_,_,_,_,_,_) = a; set1 a (_,b,c,d,e,f,g) = (a,b,c,d,e,f,g)
178
+ get2 (_,b,_,_,_,_,_) = b; set2 b (a,_,c,d,e,f,g) = (a,b,c,d,e,f,g)
179
+ get3 (_,_,c,_,_,_,_) = c; set3 c (a,b,_,d,e,f,g) = (a,b,c,d,e,f,g)
180
+ get4 (_,_,_,d,_,_,_) = d; set4 d (a,b,c,_,e,f,g) = (a,b,c,d,e,f,g)
181
+ get5 (_,_,_,_,e,_,_) = e; set5 e (a,b,c,d,_,f,g) = (a,b,c,d,e,f,g)
182
+ get6 (_,_,_,_,_,f,_) = f; set6 f (a,b,c,d,e,_,g) = (a,b,c,d,e,f,g)
183
+ get7 (_,_,_,_,_,_,g) = g; set7 g (a,b,c,d,e,f,_) = (a,b,c,d,e,f,g)
184
+
149
185
150
186
-- | The @run@ command runs a specified executable-like component, building it
151
187
-- first if necessary. The component can be either an executable, a test,
@@ -156,10 +192,12 @@ runCommand = Client.installCommand {
156
192
-- "Distribution.Client.ProjectOrchestration"
157
193
--
158
194
runAction :: ( ConfigFlags , ConfigExFlags , InstallFlags
159
- , HaddockFlags , TestFlags , BenchmarkFlags )
195
+ , HaddockFlags , TestFlags , BenchmarkFlags
196
+ , ClientRunFlags )
160
197
-> [String ] -> GlobalFlags -> IO ()
161
198
runAction ( configFlags, configExFlags, installFlags
162
- , haddockFlags, testFlags, benchmarkFlags )
199
+ , haddockFlags, testFlags, benchmarkFlags
200
+ , clientRunFlags )
163
201
targetStrings globalFlags = do
164
202
globalTmp <- getTemporaryDirectory
165
203
tempDir <- createTempDirectory globalTmp " cabal-repl."
@@ -170,7 +208,10 @@ runAction ( configFlags, configExFlags, installFlags
170
208
without config =
171
209
establishDummyProjectBaseContext verbosity (config <> cliConfig) tempDir [] OtherCommand
172
210
173
- baseCtx <- withProjectOrGlobalConfig verbosity globalConfigFlag with without
211
+ let
212
+ ignoreProject = fromFlagOrDefault False (crunIgnoreProject clientRunFlags)
213
+
214
+ baseCtx <- withProjectOrGlobalConfigIgn ignoreProject verbosity globalConfigFlag with without
174
215
175
216
let
176
217
scriptOrError script err = do
0 commit comments