Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
54099b8
Use optparse-applicative for build command
philderbeast Aug 2, 2026
5001b67
Intro and examples, no flags in usage
philderbeast Aug 2, 2026
7274928
Group options
philderbeast Aug 2, 2026
686aad6
Colorize sections
philderbeast Aug 2, 2026
e9b44f3
Colorize Usage: and Examples:
philderbeast Aug 2, 2026
84a16b5
Common starting column for flag help text
philderbeast Aug 2, 2026
378cc70
Reduce the maxFlagColumnWidth
philderbeast Aug 2, 2026
2be654f
Don't let wrapping help wrap into flag columns
philderbeast Aug 2, 2026
f2a8498
Reduce flag columns to 30
philderbeast Aug 2, 2026
a36ce48
Add bullet points for help text
philderbeast Aug 2, 2026
71e5d79
Capitalise first char of help, warn if not already
philderbeast Aug 3, 2026
18083b4
Warnings section in red
philderbeast Aug 3, 2026
685fa0d
Also make red auto-capitalized first char
philderbeast Aug 3, 2026
ba09574
Add module CommandUIOptParse
philderbeast Aug 3, 2026
e4e4d26
Add doctest for buildCommandNames
philderbeast Aug 5, 2026
dc0bbc0
Follow hlint suggestion: redundant bracket
philderbeast Aug 5, 2026
99e36ec
Follow hlint suggestions
philderbeast Aug 5, 2026
fc9d2dc
Rename remove.*Options to keep.*Options
philderbeast Aug 5, 2026
5ad78c3
Add -Wno-unused-packages to cabal-testsuite
philderbeast Aug 5, 2026
be09fb7
Add splitByKeep
philderbeast Aug 5, 2026
f1e12df
Replace splitByKeep with partition, remove splitBy
philderbeast Aug 5, 2026
f35165f
Add groupSequentially
philderbeast Aug 5, 2026
2f90ce0
Add groupPredicates
philderbeast Aug 5, 2026
5b57f59
Calculate (optsGrouped, optsUngrouped) once
philderbeast Aug 5, 2026
e7a59e9
Add allOptions
philderbeast Aug 5, 2026
819936a
Styling only
philderbeast Aug 5, 2026
23e32f9
Move helpText to CommandUIOptParse
philderbeast Aug 5, 2026
2130ec1
Move examples
philderbeast Aug 5, 2026
ba6885d
Use the examples
philderbeast Aug 5, 2026
b167e0c
Separate description
philderbeast Aug 5, 2026
c5fa888
Use fmap . fmap
philderbeast Aug 5, 2026
6f096bb
Don't reference buildCommand
philderbeast Aug 5, 2026
fc03a4f
Add cmdSpec
philderbeast Aug 5, 2026
25ba265
Follow hlint suggestion: use list comprehension
philderbeast Aug 5, 2026
aabc689
Don't import Options.Applicative qualified
philderbeast Aug 5, 2026
fdd10f7
examples taking a program name
philderbeast Aug 5, 2026
267ae35
Simplify cmdSpec
philderbeast Aug 5, 2026
9280eca
Group --enable-* with --disable-*
philderbeast Aug 6, 2026
ce27204
Use "Toggle" instead of "Enable or disable"
philderbeast Aug 6, 2026
32f168a
Use optparse-applicative with CmdInstall
philderbeast Aug 6, 2026
bd8f546
Add OptionGroupKey
philderbeast Aug 6, 2026
98a0e2d
Lambda lift renderGroup
philderbeast Aug 6, 2026
f09805f
Render the install layout group compactly
philderbeast Aug 6, 2026
6e3eefb
Move module to Client.Cmd.UI
philderbeast Aug 6, 2026
f471035
Capitalise first letter of option help
philderbeast Aug 6, 2026
e04b59a
For test-show-details, list options
philderbeast Aug 6, 2026
5bcb602
Add a deprecated group
philderbeast Aug 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions Cabal/src/Distribution/Simple/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ commandGetOpts
-> CommandUI flags
-> [GetOpt.OptDescr (flags -> flags)]
commandGetOpts showOrParse command =
concatMap viewAsGetOpt (commandOptions command showOrParse)
concatMap (viewAsGetOpt showOrParse) (commandOptions command showOrParse)

viewAsGetOpt :: OptionField a -> [GetOpt.OptDescr (a -> a)]
viewAsGetOpt (OptionField _n aa) = concatMap optDescrToGetOpt aa
viewAsGetOpt :: ShowOrParseArgs -> OptionField a -> [GetOpt.OptDescr (a -> a)]
viewAsGetOpt showOrParse (OptionField _n aa) = concatMap optDescrToGetOpt aa
where
optDescrToGetOpt (ReqArg d (cs, ss) arg_desc set _) =
[GetOpt.Option cs ss (GetOpt.ReqArg (runReadE set) arg_desc) d]
Expand All @@ -368,10 +368,27 @@ viewAsGetOpt (OptionField _n aa) = concatMap optDescrToGetOpt aa
[GetOpt.Option sfT lfT (GetOpt.NoArg (set True)) d]
optDescrToGetOpt (BoolOpt d ([], []) (sfF, lfF) set _) =
[GetOpt.Option sfF lfF (GetOpt.NoArg (set False)) d]
optDescrToGetOpt (BoolOpt d (sfT, lfT) (sfF, lfF) set _) =
[ GetOpt.Option sfT lfT (GetOpt.NoArg (set True)) ("Enable " ++ d)
, GetOpt.Option sfF lfF (GetOpt.NoArg (set False)) ("Disable " ++ d)
]
optDescrToGetOpt (BoolOpt d trueFlags@(sfT, lfT) falseFlags@(sfF, lfF) set _) =
case showOrParse of
ShowArgs
| Just groupedLongFlag <- mkGroupedBoolLongFlag trueFlags falseFlags ->
[ GetOpt.Option [] [groupedLongFlag] (GetOpt.NoArg (set True)) ("Toggle " ++ d)
]
_ ->
[ GetOpt.Option sfT lfT (GetOpt.NoArg (set True)) ("Enable " ++ d)
, GetOpt.Option sfF lfF (GetOpt.NoArg (set False)) ("Disable " ++ d)
]

mkGroupedBoolLongFlag :: OptFlags -> OptFlags -> Maybe String
mkGroupedBoolLongFlag ([], [longA]) ([], [longB]) =
checkPair longA longB <|> checkPair longB longA
where
checkPair longEnable longDisable = do
suffixEnable <- List.stripPrefix "enable-" longEnable
suffixDisable <- List.stripPrefix "disable-" longDisable
guard (suffixEnable == suffixDisable)
pure ("[enable|disable]-" ++ suffixEnable)
mkGroupedBoolLongFlag _ _ = Nothing

getCurrentChoice :: OptDescr a -> a -> [String]
getCurrentChoice (ChoiceOpt alts) a =
Expand Down
4 changes: 2 additions & 2 deletions Cabal/src/Distribution/Simple/Setup/Benchmark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ benchmarkOptions' showOrParseArgs =
[ option
[]
["benchmark-options"]
( "give extra options to benchmark executables "
( "Give extra options to benchmark executables "
++ "(split on spaces, use \"\" to prevent splitting; "
++ "name templates can use $pkgid, $compiler, "
++ "$os, $arch, $benchmark)"
Expand All @@ -131,7 +131,7 @@ benchmarkOptions' showOrParseArgs =
, option
[]
["benchmark-option"]
( "give extra option to benchmark executables "
( "Give extra option to benchmark executables "
++ "(passed directly as a single argument; "
++ "name template can use $pkgid, $compiler, "
++ "$os, $arch, $benchmark)"
Expand Down
6 changes: 3 additions & 3 deletions Cabal/src/Distribution/Simple/Setup/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ programDbPaths' mkName progDb showOrParseArgs get set =
option
""
[mkName prog]
("give the path to " ++ prog)
("Give the path to " ++ prog)
get
set
( reqArg'
Expand Down Expand Up @@ -267,7 +267,7 @@ programDbOption progDb showOrParseArgs get set =
option
""
[prog ++ "-option"]
( "give an extra option to "
( "Give an extra option to "
++ prog
++ " (passed directly to "
++ prog
Expand Down Expand Up @@ -308,7 +308,7 @@ programDbOptions progDb showOrParseArgs get set =
option
""
[prog ++ "-options"]
( "give extra options to "
( "Give extra options to "
++ prog
++ " (split on spaces, use \"\" to prevent splitting)"
)
Expand Down
12 changes: 6 additions & 6 deletions Cabal/src/Distribution/Simple/Setup/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -434,22 +434,22 @@ configureOptions showOrParseArgs =
configHcFlavor
(\v flags -> flags{configHcFlavor = v})
( choiceOpt
[ (Flag GHC, ("g", ["ghc"]), "compile with GHC")
, (Flag GHCJS, ([], ["ghcjs"]), "compile with GHCJS")
, (Flag UHC, ([], ["uhc"]), "compile with UHC")
[ (Flag GHC, ("g", ["ghc"]), "Compile with GHC")
, (Flag GHCJS, ([], ["ghcjs"]), "Compile with GHCJS")
, (Flag UHC, ([], ["uhc"]), "Compile with UHC")
]
)
, option
"w"
["with-compiler"]
"give the path to a particular compiler"
"Give the path to a particular compiler"
configHcPath
(\v flags -> flags{configHcPath = v})
(reqArgFlag "PATH")
, option
""
["with-hc-pkg"]
"give the path to the package tool"
"Give the path to the package tool"
configHcPkg
(\v flags -> flags{configHcPkg = v})
(reqArgFlag "PATH")
Expand Down Expand Up @@ -841,7 +841,7 @@ configureOptions showOrParseArgs =
, option
""
["response-files"]
"enable workaround for old versions of programs like \"ar\" that do not support @file arguments"
"Enable workaround for old versions of programs like \"ar\" that do not support @file arguments"
configUseResponseFiles
(\v flags -> flags{configUseResponseFiles = v})
(boolOpt' ([], ["disable-response-files"]) ([], []))
Expand Down
19 changes: 11 additions & 8 deletions Cabal/src/Distribution/Simple/Setup/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,14 @@ testOptions' showOrParseArgs =
, option
[]
["show-details"]
( "'always': always show results of individual test cases. "
++ "'never': never show results of individual test cases. "
++ "'failures': show results of failing test cases. "
++ "'streaming': show results of test cases in real time."
++ "'direct': send results of test cases in real time; no log file."
( unlines
[ "Allowed values:"
, "- always: always show results of individual test cases."
, "- never: never show results of individual test cases."
, "- failures: show results of failing test cases."
, "- streaming: show results of test cases in real time."
, "- direct: send results of test cases in real time; no log file."
]
)
testShowDetails
(\v flags -> flags{testShowDetails = v})
Expand All @@ -218,7 +221,7 @@ testOptions' showOrParseArgs =
, option
[]
["keep-tix-files"]
"keep .tix files for HPC between test runs"
"Keep .tix files for HPC between test runs"
testKeepTix
(\v flags -> flags{testKeepTix = v})
trueArg
Expand All @@ -243,7 +246,7 @@ testOptions' showOrParseArgs =
, option
[]
["test-options"]
( "give extra options to test executables "
( "Give extra options to test executables "
++ "(split on spaces, use \"\" to prevent splitting; "
++ "name templates can use $pkgid, $compiler, "
++ "$os, $arch, $test-suite)"
Expand All @@ -258,7 +261,7 @@ testOptions' showOrParseArgs =
, option
[]
["test-option"]
( "give extra option to test executables "
( "Give extra option to test executables "
++ "(passed directly as a single argument; "
++ "name template can use $pkgid, $compiler, "
++ "$os, $arch, $test-suite)"
Expand Down
2 changes: 2 additions & 0 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ library
Distribution.Client.CmdClean
Distribution.Client.CmdConfigure
Distribution.Client.CmdErrorMessages
Distribution.Client.Cmd.UI
Distribution.Client.CmdExec
Distribution.Client.CmdFreeze
Distribution.Client.CmdHaddock
Expand Down Expand Up @@ -256,6 +257,7 @@ library
, HTTP >= 4000.1.5 && < 4000.6
, mtl >= 2.0 && < 2.4
, network-uri >= 2.6.2.0 && < 2.7
, optparse-applicative >= 0.18 && < 0.19
, pretty >= 1.1 && < 1.2
, process >= 1.2.3.0 && < 1.6.24 || == 1.6.26.0 || >= 1.6.26.2 && < 1.7
, random >= 1.2 && < 1.4
Expand Down
Loading
Loading