Skip to content

Commit 49a1dab

Browse files
bgamarilukel97
authored andcommitted
Add show-build-info command
This allows users to get a JSON representation of various information about how Cabal would go about building a package. The output of this command is intended for external tools and therefore the format should remain stable.
1 parent f7d1b4e commit 49a1dab

File tree

1 file changed

+22
-1
lines changed
  • cabal-install/Distribution/Client

1 file changed

+22
-1
lines changed

cabal-install/Distribution/Client/Setup.hs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Distribution.Client.Setup
2323
, configureExCommand, ConfigExFlags(..), defaultConfigExFlags
2424
, buildCommand, BuildFlags(..), BuildExFlags(..), SkipAddSourceDepsCheck(..)
2525
, filterTestFlags
26-
, replCommand, testCommand, benchmarkCommand, testOptions, benchmarkOptions
26+
, replCommand, testCommand, showBuildInfoCommand, benchmarkCommand, testOptions, benchmarkOptions
2727
, configureExOptions, reconfigureCommand
2828
, installCommand, InstallFlags(..), installOptions, defaultInstallFlags
2929
, filterHaddockArgs, filterHaddockFlags, haddockOptions
@@ -192,6 +192,7 @@ globalCommand commands = CommandUI {
192192
, "outdated"
193193
, "haddock"
194194
, "hscolour"
195+
, "show-build-info"
195196
, "exec"
196197
, "new-build"
197198
, "new-configure"
@@ -278,6 +279,7 @@ globalCommand commands = CommandUI {
278279
, addCmd "upload"
279280
, addCmd "report"
280281
, par
282+
, addCmd "show-build-info"
281283
, addCmd "freeze"
282284
, addCmd "gen-bounds"
283285
, addCmd "outdated"
@@ -861,6 +863,25 @@ filterTestFlags flags cabalLibVersion
861863
Cabal.testWrapper = NoFlag
862864
}
863865

866+
-- ------------------------------------------------------------
867+
-- * show-build-info command
868+
-- ------------------------------------------------------------
869+
870+
showBuildInfoCommand :: CommandUI (BuildFlags, BuildExFlags)
871+
showBuildInfoCommand = parent {
872+
commandDefaultFlags = (commandDefaultFlags parent, mempty),
873+
commandOptions =
874+
\showOrParseArgs -> liftOptions fst setFst
875+
(commandOptions parent showOrParseArgs)
876+
++
877+
liftOptions snd setSnd (buildExOptions showOrParseArgs)
878+
}
879+
where
880+
setFst a (_,b) = (a,b)
881+
setSnd b (a,_) = (a,b)
882+
883+
parent = Cabal.showBuildInfoCommand defaultProgramDb
884+
864885
-- ------------------------------------------------------------
865886
-- * Repl command
866887
-- ------------------------------------------------------------

0 commit comments

Comments
 (0)