@@ -49,6 +49,7 @@ module Distribution.Client.Setup
49
49
, execCommand , ExecFlags (.. ), defaultExecFlags
50
50
, userConfigCommand , UserConfigFlags (.. )
51
51
, manpageCommand
52
+ , haddockCommand
52
53
53
54
, parsePackageArgs
54
55
-- TODO: stop exporting these:
@@ -402,15 +403,24 @@ globalCommand commands = CommandUI {
402
403
403
404
configureCommand :: CommandUI ConfigFlags
404
405
configureCommand = c
405
- { commandDefaultFlags = mempty
406
+ { commandName = " v1-configure"
407
+ , commandDefaultFlags = mempty
408
+ , commandDescription = Just $ \ _ -> wrapText $
409
+ " Configure how the package is built by setting "
410
+ ++ " package (and other) flags.\n "
411
+ ++ " \n "
412
+ ++ " The configuration affects several other commands, "
413
+ ++ " including v1-build, v1-test, v1-bench, v1-run, v1-repl.\n "
414
+ , commandUsage = \ pname ->
415
+ " Usage: " ++ pname ++ " v1-configure [FLAGS]\n "
406
416
, commandNotes = Just $ \ pname ->
407
- (Cabal. programFlagsDescription defaultProgramDb ++ " \n " )
408
- ++ " Examples:\n "
409
- ++ " " ++ pname ++ " v1-configure\n "
410
- ++ " Configure with defaults;\n "
411
- ++ " " ++ pname ++ " v1-configure --enable-tests -fcustomflag\n "
412
- ++ " Configure building package including tests,\n "
413
- ++ " with some package-specific flag.\n "
417
+ (Cabal. programFlagsDescription defaultProgramDb ++ " \n " )
418
+ ++ " Examples:\n "
419
+ ++ " " ++ pname ++ " v1-configure\n "
420
+ ++ " Configure with defaults;\n "
421
+ ++ " " ++ pname ++ " v1-configure --enable-tests -fcustomflag\n "
422
+ ++ " Configure building package including tests,\n "
423
+ ++ " with some package-specific flag.\n "
414
424
}
415
425
where
416
426
c = Cabal. configureCommand defaultProgramDb
@@ -680,7 +690,14 @@ buildExOptions _showOrParseArgs =
680
690
681
691
buildCommand :: CommandUI (BuildFlags , BuildExFlags )
682
692
buildCommand = parent {
693
+ commandName = " build" ,
694
+ commandDescription = Just $ \ _ -> wrapText $
695
+ " Components encompass executables, tests, and benchmarks.\n "
696
+ ++ " \n "
697
+ ++ " Affected by configuration options, see `v1-configure`.\n " ,
683
698
commandDefaultFlags = (commandDefaultFlags parent, mempty ),
699
+ commandUsage = usageAlternatives " v1-build" $
700
+ [ " [FLAGS]" , " COMPONENTS [FLAGS]" ],
684
701
commandOptions =
685
702
\ showOrParseArgs -> liftOptions fst setFst
686
703
(commandOptions parent showOrParseArgs)
@@ -713,6 +730,26 @@ instance Semigroup BuildExFlags where
713
730
714
731
replCommand :: CommandUI (ReplFlags , BuildExFlags )
715
732
replCommand = parent {
733
+ commandName = " repl" ,
734
+ commandDescription = Just $ \ pname -> wrapText $
735
+ " If the current directory contains no package, ignores COMPONENT "
736
+ ++ " parameters and opens an interactive interpreter session; if a "
737
+ ++ " sandbox is present, its package database will be used.\n "
738
+ ++ " \n "
739
+ ++ " Otherwise, (re)configures with the given or default flags, and "
740
+ ++ " loads the interpreter with the relevant modules. For executables, "
741
+ ++ " tests and benchmarks, loads the main module (and its "
742
+ ++ " dependencies); for libraries all exposed/other modules.\n "
743
+ ++ " \n "
744
+ ++ " The default component is the library itself, or the executable "
745
+ ++ " if that is the only component.\n "
746
+ ++ " \n "
747
+ ++ " Support for loading specific modules is planned but not "
748
+ ++ " implemented yet. For certain scenarios, `" ++ pname
749
+ ++ " v1-exec -- ghci :l Foo` may be used instead. Note that `v1-exec` will "
750
+ ++ " not (re)configure and you will have to specify the location of "
751
+ ++ " other modules, if required.\n " ,
752
+ commandUsage = \ pname -> " Usage: " ++ pname ++ " v1-repl [COMPONENT] [FLAGS]\n " ,
716
753
commandDefaultFlags = (commandDefaultFlags parent, mempty ),
717
754
commandOptions =
718
755
\ showOrParseArgs -> liftOptions fst setFst
@@ -740,6 +777,19 @@ replCommand = parent {
740
777
741
778
testCommand :: CommandUI (TestFlags , BuildFlags , BuildExFlags )
742
779
testCommand = parent {
780
+ commandName = " test" ,
781
+ commandDescription = Just $ \ pname -> wrapText $
782
+ " If necessary (re)configures with `--enable-tests` flag and builds"
783
+ ++ " the test suite.\n "
784
+ ++ " \n "
785
+ ++ " Remember that the tests' dependencies must be installed if there"
786
+ ++ " are additional ones; e.g. with `" ++ pname
787
+ ++ " v1-install --only-dependencies --enable-tests`.\n "
788
+ ++ " \n "
789
+ ++ " By defining UserHooks in a custom Setup.hs, the package can"
790
+ ++ " define actions to be executed before and after running tests.\n " ,
791
+ commandUsage = usageAlternatives " v1-test"
792
+ [ " [FLAGS]" , " TESTCOMPONENTS [FLAGS]" ],
743
793
commandDefaultFlags = (commandDefaultFlags parent,
744
794
Cabal. defaultBuildFlags, mempty ),
745
795
commandOptions =
@@ -765,6 +815,20 @@ testCommand = parent {
765
815
766
816
benchmarkCommand :: CommandUI (BenchmarkFlags , BuildFlags , BuildExFlags )
767
817
benchmarkCommand = parent {
818
+ commandName = " bench" ,
819
+ commandUsage = usageAlternatives " v1-bench"
820
+ [ " [FLAGS]" , " BENCHCOMPONENTS [FLAGS]" ],
821
+ commandDescription = Just $ \ pname -> wrapText $
822
+ " If necessary (re)configures with `--enable-benchmarks` flag and"
823
+ ++ " builds the benchmarks.\n "
824
+ ++ " \n "
825
+ ++ " Remember that the benchmarks' dependencies must be installed if"
826
+ ++ " there are additional ones; e.g. with `" ++ pname
827
+ ++ " v1-install --only-dependencies --enable-benchmarks`.\n "
828
+ ++ " \n "
829
+ ++ " By defining UserHooks in a custom Setup.hs, the package can"
830
+ ++ " define actions to be executed before and after running"
831
+ ++ " benchmarks.\n " ,
768
832
commandDefaultFlags = (commandDefaultFlags parent,
769
833
Cabal. defaultBuildFlags, mempty ),
770
834
commandOptions =
@@ -1125,7 +1189,7 @@ updateCommand = CommandUI {
1125
1189
relevantConfigValuesText [" remote-repo"
1126
1190
," remote-repo-cache"
1127
1191
," local-repo" ],
1128
- commandUsage = usageFlags " update" ,
1192
+ commandUsage = usageFlags " v1- update" ,
1129
1193
commandDefaultFlags = defaultUpdateFlags,
1130
1194
commandOptions = \ _ -> [
1131
1195
optionVerbosity updateVerbosity (\ v flags -> flags { updateVerbosity = v }),
@@ -1227,15 +1291,15 @@ runCommand = CommandUI {
1227
1291
++ " specified, but the package contains just one executable, that one "
1228
1292
++ " is built and executed.\n "
1229
1293
++ " \n "
1230
- ++ " Use `" ++ pname ++ " test --show-details=streaming` to run a "
1294
+ ++ " Use `" ++ pname ++ " v1- test --show-details=streaming` to run a "
1231
1295
++ " test-suite and get its full output.\n " ,
1232
1296
commandNotes = Just $ \ pname ->
1233
1297
" Examples:\n "
1234
1298
++ " " ++ pname ++ " v1-run\n "
1235
1299
++ " Run the only executable in the current package;\n "
1236
1300
++ " " ++ pname ++ " v1-run foo -- --fooflag\n "
1237
1301
++ " Works similar to `./foo --fooflag`.\n " ,
1238
- commandUsage = usageAlternatives " run"
1302
+ commandUsage = usageAlternatives " v1- run"
1239
1303
[" [FLAGS] [EXECUTABLE] [-- EXECUTABLE_FLAGS]" ],
1240
1304
commandDefaultFlags = mempty ,
1241
1305
commandOptions =
@@ -1613,7 +1677,7 @@ installCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFl
1613
1677
installCommand = CommandUI {
1614
1678
commandName = " install" ,
1615
1679
commandSynopsis = " Install packages." ,
1616
- commandUsage = usageAlternatives " install" [ " [FLAGS]"
1680
+ commandUsage = usageAlternatives " v1- install" [ " [FLAGS]"
1617
1681
, " [FLAGS] PACKAGES"
1618
1682
],
1619
1683
commandDescription = Just $ \ _ -> wrapText $
@@ -1626,12 +1690,12 @@ installCommand = CommandUI {
1626
1690
++ " dependencies) (there must be exactly one .cabal file in the current"
1627
1691
++ " directory).\n "
1628
1692
++ " \n "
1629
- ++ " When using a sandbox, the flags for `install` only affect the"
1693
+ ++ " When using a sandbox, the flags for `v1- install` only affect the"
1630
1694
++ " current command and have no effect on future commands. (To achieve"
1631
- ++ " that, `configure` must be used.)\n "
1632
- ++ " In contrast, without a sandbox, the flags to `install` are saved and"
1633
- ++ " affect future commands such as `build` and `repl`. See the help for"
1634
- ++ " `configure` for a list of commands being affected.\n "
1695
+ ++ " that, `v1- configure` must be used.)\n "
1696
+ ++ " In contrast, without a sandbox, the flags to `v1- install` are saved and"
1697
+ ++ " affect future commands such as `v1- build` and `v1- repl`. See the help for"
1698
+ ++ " `v1- configure` for a list of commands being affected.\n "
1635
1699
++ " \n "
1636
1700
++ " Installed executables will by default (and without a sandbox)"
1637
1701
++ " be put into `~/.cabal/bin/`."
@@ -1687,6 +1751,13 @@ installCommand = CommandUI {
1687
1751
get3 (_,_,c,_) = c; set3 c (a,b,_,d) = (a,b,c,d)
1688
1752
get4 (_,_,_,d) = d; set4 d (a,b,c,_) = (a,b,c,d)
1689
1753
1754
+ haddockCommand :: CommandUI HaddockFlags
1755
+ haddockCommand = Cabal. haddockCommand
1756
+ { commandName = " v1-haddock"
1757
+ , commandUsage = usageAlternatives " v1-haddock" $
1758
+ [ " [FLAGS]" , " COMPONENTS [FLAGS]" ]
1759
+ }
1760
+
1690
1761
filterHaddockArgs :: [String ] -> Version -> [String ]
1691
1762
filterHaddockArgs args cabalLibVersion
1692
1763
| cabalLibVersion >= mkVersion [2 ,3 ,0 ] = args_latest
@@ -2427,20 +2498,20 @@ execCommand = CommandUI {
2427
2498
-- TODO: this is too GHC-focused for my liking..
2428
2499
" A directly invoked GHC will not automatically be aware of any"
2429
2500
++ " sandboxes: the GHC_PACKAGE_PATH environment variable controls what"
2430
- ++ " GHC uses. `" ++ pname ++ " exec` can be used to modify this variable:"
2501
+ ++ " GHC uses. `" ++ pname ++ " v1- exec` can be used to modify this variable:"
2431
2502
++ " COMMAND will be executed in a modified environment and thereby uses"
2432
2503
++ " the sandbox package database.\n "
2433
2504
++ " \n "
2434
2505
++ " If there is no sandbox, behaves as identity (executing COMMAND).\n "
2435
2506
++ " \n "
2436
2507
++ " Note that other " ++ pname ++ " commands change the environment"
2437
2508
++ " variable appropriately already, so there is no need to wrap those"
2438
- ++ " in `" ++ pname ++ " exec`. But with `" ++ pname ++ " exec`, the user"
2509
+ ++ " in `" ++ pname ++ " v1- exec`. But with `" ++ pname ++ " v1- exec`, the user"
2439
2510
++ " has more control and can, for example, execute custom scripts which"
2440
2511
++ " indirectly execute GHC.\n "
2441
2512
++ " \n "
2442
- ++ " Note that `" ++ pname ++ " repl` is different from `" ++ pname
2443
- ++ " exec -- ghci` as the latter will not forward any additional flags"
2513
+ ++ " Note that `" ++ pname ++ " v1- repl` is different from `" ++ pname
2514
+ ++ " v1- exec -- ghci` as the latter will not forward any additional flags"
2444
2515
++ " being defined in the local package to ghci.\n "
2445
2516
++ " \n "
2446
2517
++ " See `" ++ pname ++ " sandbox`.\n " ,
@@ -2454,7 +2525,7 @@ execCommand = CommandUI {
2454
2525
++ " Execute runghc on Foo.hs with runghc configured to use the\n "
2455
2526
++ " sandbox package database (if a sandbox is being used).\n " ,
2456
2527
commandUsage = \ pname ->
2457
- " Usage: " ++ pname ++ " exec [FLAGS] [--] COMMAND [--] [ARGS]\n " ,
2528
+ " Usage: " ++ pname ++ " v1- exec [FLAGS] [--] COMMAND [--] [ARGS]\n " ,
2458
2529
2459
2530
commandDefaultFlags = defaultExecFlags,
2460
2531
commandOptions = \ showOrParseArgs ->
0 commit comments