Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
a205566
Use optparse-applicative for build command
philderbeast Aug 2, 2026
06dbf34
Intro and examples, no flags in usage
philderbeast Aug 2, 2026
ee50592
Group options
philderbeast Aug 2, 2026
9838aa2
Colorize sections
philderbeast Aug 2, 2026
6c36687
Colorize Usage: and Examples:
philderbeast Aug 2, 2026
e4167cb
Common starting column for flag help text
philderbeast Aug 2, 2026
2ffe51a
Reduce the maxFlagColumnWidth
philderbeast Aug 2, 2026
990fe71
Don't let wrapping help wrap into flag columns
philderbeast Aug 2, 2026
03cc352
Reduce flag columns to 30
philderbeast Aug 2, 2026
a5227bd
Add bullet points for help text
philderbeast Aug 2, 2026
98ff99f
Capitalise first char of help, warn if not already
philderbeast Aug 3, 2026
cb07505
Warnings section in red
philderbeast Aug 3, 2026
6f9c2a3
Also make red auto-capitalized first char
philderbeast Aug 3, 2026
d3bc2b2
Add module CommandUIOptParse
philderbeast Aug 3, 2026
e8de204
Add doctest for buildCommandNames
philderbeast Aug 5, 2026
d02100b
Follow hlint suggestion: redundant bracket
philderbeast Aug 5, 2026
81d6fba
Follow hlint suggestions
philderbeast Aug 5, 2026
92f1adc
Rename remove.*Options to keep.*Options
philderbeast Aug 5, 2026
c7fcfeb
Add -Wno-unused-packages to cabal-testsuite
philderbeast Aug 5, 2026
f7590ec
Add splitByKeep
philderbeast Aug 5, 2026
c3d631e
Replace splitByKeep with partition, remove splitBy
philderbeast Aug 5, 2026
63b5a4c
Add groupSequentially
philderbeast Aug 5, 2026
06a5995
Add groupPredicates
philderbeast Aug 5, 2026
09034ab
Calculate (optsGrouped, optsUngrouped) once
philderbeast Aug 5, 2026
403e482
Add allOptions
philderbeast Aug 5, 2026
b9e72f0
Styling only
philderbeast Aug 5, 2026
16b2d00
Move helpText to CommandUIOptParse
philderbeast Aug 5, 2026
adc84b6
Move examples
philderbeast Aug 5, 2026
c4fec5d
Use the examples
philderbeast Aug 5, 2026
2682cd6
Separate description
philderbeast Aug 5, 2026
68bef0e
Use fmap . fmap
philderbeast Aug 5, 2026
c09ced8
Don't reference buildCommand
philderbeast Aug 5, 2026
31eff53
Add cmdSpec
philderbeast Aug 5, 2026
f15450d
Follow hlint suggestion: use list comprehension
philderbeast Aug 5, 2026
2f4010a
Don't import Options.Applicative qualified
philderbeast Aug 5, 2026
e973dc8
examples taking a program name
philderbeast Aug 5, 2026
687a7fd
Simplify cmdSpec
philderbeast Aug 5, 2026
72b05c1
Group --enable-* with --disable-*
philderbeast Aug 6, 2026
610941c
Use "Toggle" instead of "Enable or disable"
philderbeast Aug 6, 2026
1b2291d
Use optparse-applicative with CmdInstall
philderbeast Aug 6, 2026
566741b
Add OptionGroupKey
philderbeast Aug 6, 2026
583a8c4
Lambda lift renderGroup
philderbeast Aug 6, 2026
7ecce5e
Render the install layout group compactly
philderbeast Aug 6, 2026
759ad50
Move module to Client.Cmd.UI
philderbeast Aug 6, 2026
1939573
For test-show-details, list options
philderbeast Aug 6, 2026
2c3fc83
Add a deprecated group
philderbeast Aug 7, 2026
56cca34
Generalise CmdItem
philderbeast Aug 10, 2026
7afd8a9
Generalise *OptionParsers
philderbeast Aug 11, 2026
d075ad4
Move cmdOptionParsers
philderbeast Aug 11, 2026
e45886b
Move cmdItemParser
philderbeast Aug 11, 2026
e22fe31
Move parsedCommandParser
philderbeast Aug 11, 2026
0a549bb
Move helpDescriptionOrSynopsis
philderbeast Aug 11, 2026
127720b
Move parserInfo
philderbeast Aug 11, 2026
bd1c556
Rename to isCommandName
philderbeast Aug 13, 2026
2e6c5a2
Rename to parseCommand
philderbeast Aug 13, 2026
017f20c
Use do block to reduce repetition
philderbeast Aug 13, 2026
b544571
Satisfy fourmolu
philderbeast Aug 13, 2026
d8a80f6
Replace FILTER with values for test-show-details
philderbeast Aug 15, 2026
a75f679
Replace LEVEL with values for remote-build-report
philderbeast Aug 15, 2026
cd3bf85
Sublist for remote-build-reporting options
philderbeast Aug 15, 2026
44ba149
act-as-setup warning and error
philderbeast Aug 15, 2026
a2d60a2
HasCallStack for getConfigState
philderbeast Aug 16, 2026
df82ea1
Replace BUILD-TYPE with values for BuildType
philderbeast Aug 16, 2026
7d22cd9
Move cmdSpec to Cmd.UI
philderbeast Aug 16, 2026
a2042eb
Use Cmd.UI.cmdSpec
philderbeast Aug 16, 2026
02b0bf1
Move parseCommand to Cmd.UI
philderbeast Aug 16, 2026
1c4529c
Move replaceCommandAlias to Cmd.UI
philderbeast Aug 16, 2026
f957f1a
Move cmdListOptions to Cmd.UI
philderbeast Aug 16, 2026
d1ee347
Change arg order of parseCommand
philderbeast Aug 16, 2026
f411558
Simplify CommandReadyToGo
philderbeast Aug 16, 2026
1727cd0
Satisfy HLint
philderbeast Aug 16, 2026
a9ebfb5
Move changes to one region of module
philderbeast Aug 16, 2026
1bfb9c3
Get rid of isCommandName
philderbeast Aug 16, 2026
242c6ea
Add commandNames
philderbeast Aug 16, 2026
4dde573
Use replace from generic-sop-lens
philderbeast Aug 16, 2026
02bc75c
Rename defaultMsg to stripVersionPrefix
philderbeast Aug 16, 2026
0dedd2d
Move ReplaceCommandAlias
philderbeast Aug 16, 2026
a695203
Add haddocks to Examples
philderbeast Aug 17, 2026
2b9518c
Addhaddocks for ReplaceCommandAlias
philderbeast Aug 17, 2026
22b3dd5
Add haddocks to prefix functions
philderbeast Aug 17, 2026
b400d3b
Add haddocks to replaceCommandAlias
philderbeast Aug 17, 2026
3436804
Move parseCommandWithOptParse to Cmd.UI
philderbeast Aug 18, 2026
50af50b
Remove parseCommand wrappers
philderbeast Aug 18, 2026
dcfb788
Add parseCommandWithOptparseMany
philderbeast Aug 18, 2026
329927f
Renaming and use parseMany
philderbeast Aug 18, 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
7 changes: 3 additions & 4 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module Distribution.Simple.Configure

import Control.Monad
import Distribution.Compat.Prelude
import GHC.Stack (HasCallStack)
import Prelude ()

import Distribution.Backpack.Configure
Expand All @@ -81,7 +82,6 @@ import Distribution.Backpack.DescribeUnitId
import Distribution.Backpack.Id
import Distribution.Backpack.PreExistingComponent
import qualified Distribution.Compat.Graph as Graph
import Distribution.Compat.Stack
import Distribution.Compiler
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import qualified Distribution.InstalledPackageInfo as IPI
Expand Down Expand Up @@ -253,7 +253,8 @@ instance Exception ConfigStateFileError
-- missing, if the file cannot be read, or if the file was created by an older
-- version of Cabal.
getConfigStateFile
:: Maybe (SymbolicPath CWD (Dir Pkg))
:: HasCallStack
=> Maybe (SymbolicPath CWD (Dir Pkg))
-> SymbolicPath Pkg File
-- ^ The file path of the @setup-config@ file.
-> IO LocalBuildInfo
Expand All @@ -279,8 +280,6 @@ getConfigStateFile mbWorkDir setupConfigFile = do
throwIO $ ConfigStateFileBadVersion cabalId compId eResult
| otherwise = act
deferErrorIfBadVersion getStoredValue
where
_ = callStack -- TODO: attach call stack to exception

-- | Read the 'localBuildInfoFile', returning either an error or the local build
-- info.
Expand Down
15 changes: 9 additions & 6 deletions Cabal/src/Distribution/Simple/Setup/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,19 @@ 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})
( reqArg
"FILTER"
"always|never|failures|streaming|direct"
( parsecToReadE
( \_ ->
"--show-details flag expects one of "
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.6.29.0 && < 1.7
, random >= 1.2 && < 1.4
Expand Down
Loading
Loading