Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -340,10 +340,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 @@ -358,10 +358,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
10 changes: 10 additions & 0 deletions changelog.d/12425.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
synopsis: Show --enable and --disable flag pairs as one
packages: [Cabal]
prs: 12426
issues: 12425
---

In command `--help` output, boolean option matched pairs that have an
`--enable-foo` and `--disable-foo` form are now shown as a single
`--[enable|disable]-foo` option.
100 changes: 37 additions & 63 deletions doc/cmd-v1-help/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,24 @@ Flags for v1-configure:
--sysconfdir=DIR # Installation directory for configuration files
--program-prefix=PREFIX # Prefix to be applied to installed executables
--program-suffix=SUFFIX # Suffix to be applied to installed executables
--enable-library-vanilla # Enable Vanilla libraries
--disable-library-vanilla # Disable Vanilla libraries
--[enable|disable]-library-vanilla
# Toggle Vanilla libraries
-p, --enable-library-profiling
# Enable Library profiling
--disable-library-profiling # Disable Library profiling
--enable-shared # Enable Shared library
--disable-shared # Disable Shared library
--enable-static # Enable Static library
--disable-static # Disable Static library
--enable-library-bytecode # Enable Bytecode library
--disable-library-bytecode # Disable Bytecode library
--enable-executable-dynamic # Enable Executable dynamic linking
--disable-executable-dynamic # Disable Executable dynamic linking
--enable-executable-static # Enable Executable fully static linking
--disable-executable-static # Disable Executable fully static linking
--enable-profiling # Enable Executable and library profiling
--disable-profiling # Disable Executable and library profiling
--enable-profiling-shared # Enable Build profiling shared libraries
--disable-profiling-shared # Disable Build profiling shared libraries
--enable-executable-profiling
# Enable Executable profiling (DEPRECATED)
--disable-executable-profiling
# Disable Executable profiling (DEPRECATED)
--[enable|disable]-shared # Toggle Shared library
--[enable|disable]-static # Toggle Static library
--[enable|disable]-library-bytecode
# Toggle Bytecode library
--[enable|disable]-executable-dynamic
# Toggle Executable dynamic linking
--[enable|disable]-executable-static
# Toggle Executable fully static linking
--[enable|disable]-profiling # Toggle Executable and library profiling
--[enable|disable]-profiling-shared
# Toggle Build profiling shared libraries
--[enable|disable]-executable-profiling
# Toggle Executable profiling (DEPRECATED)
--profiling-detail=level # Profiling detail level for executable and
library (default, none, exported-functions,
toplevel-functions, all-functions, late).
Expand All @@ -79,27 +74,20 @@ Flags for v1-configure:
project building
--disable-build-info # Disable build information generation during
project building
--enable-library-for-ghci # Enable compile library for use with GHCi
--disable-library-for-ghci # Disable compile library for use with GHCi
--enable-split-sections # Enable compile library code such that unneeded
--[enable|disable]-library-for-ghci
# Toggle compile library for use with GHCi
--[enable|disable]-split-sections
# Toggle compile library code such that unneeded
definitions can be dropped from the final
executable (GHC 7.8+)
--disable-split-sections # Disable compile library code such that
unneeded definitions can be dropped from the
final executable (GHC 7.8+)
--enable-split-objs # Enable split library into smaller objects to
--[enable|disable]-split-objs
# Toggle split library into smaller objects to
reduce binary sizes (GHC 6.6+)
--disable-split-objs # Disable split library into smaller objects to
reduce binary sizes (GHC 6.6+)
--enable-executable-stripping
# Enable strip executables upon installation to
reduce binary sizes
--disable-executable-stripping
# Disable strip executables upon installation to
--[enable|disable]-executable-stripping
# Toggle strip executables upon installation to
reduce binary sizes
--enable-library-stripping # Enable strip libraries upon installation to
reduce binary sizes
--disable-library-stripping # Disable strip libraries upon installation to
--[enable|disable]-library-stripping
# Toggle strip libraries upon installation to
reduce binary sizes
--configure-option=OPT # Extra option for configure
--user # Enable doing a per-user installation
Expand All @@ -120,9 +108,8 @@ Flags for v1-configure:
false.
--extra-include-dirs=PATH # A list of directories to search for header
files
--enable-deterministic # Enable Try to be as deterministic as possible
(used by the test suite)
--disable-deterministic # Disable Try to be as deterministic as possible
--[enable|disable]-deterministic
# Toggle Try to be as deterministic as possible
(used by the test suite)
--ipid=IPID # Installed package ID to compile this package
as
Expand All @@ -140,30 +127,21 @@ Flags for v1-configure:
locations)
--instantiate-with=NAME=MOD # A mapping of signature names to concrete
module instantiations.
--enable-tests # Enable dependency checking and compilation for
--[enable|disable]-tests # Toggle dependency checking and compilation for
test suites listed in the package description
file.
--disable-tests # Disable dependency checking and compilation
for test suites listed in the package
description file.
--enable-coverage # Enable build package with Haskell Program
--[enable|disable]-coverage # Toggle build package with Haskell Program
Coverage. (GHC only)
--disable-coverage # Disable build package with Haskell Program
Coverage. (GHC only)
--enable-library-coverage # Enable build package with Haskell Program
Coverage. (GHC only) (DEPRECATED)
--disable-library-coverage # Disable build package with Haskell Program
--[enable|disable]-library-coverage
# Toggle build package with Haskell Program
Coverage. (GHC only) (DEPRECATED)
--enable-benchmarks # Enable dependency checking and compilation for
--[enable|disable]-benchmarks
# Toggle dependency checking and compilation for
benchmarks listed in the package description
file.
--disable-benchmarks # Disable dependency checking and compilation
for benchmarks listed in the package
description file.
--enable-relocatable # Enable building a package that is relocatable.
--[enable|disable]-relocatable
# Toggle building a package that is relocatable.
(GHC only)
--disable-relocatable # Disable building a package that is
relocatable. (GHC only)
--disable-response-files # Enable workaround for old versions of programs
like "ar" that do not support @file arguments
--allow-depending-on-private-libs
Expand All @@ -182,13 +160,9 @@ Flags for v1-configure:
use "" to prevent splitting)
--cabal-lib-version=VERSION # Select which version of the Cabal lib to use
to build packages (useful for testing).
--enable-append # Enable appending the new config to the old
--[enable|disable]-append # Toggle appending the new config to the old
config file
--disable-append # Disable appending the new config to the old
config file
--enable-backup # Enable the backup of the config file before
any alterations
--disable-backup # Disable the backup of the config file before
--[enable|disable]-backup # Toggle the backup of the config file before
any alterations
-c CONSTRAINT or -cCONSTRAINT, --constraint=CONSTRAINT
# Specify constraints on a package (version,
Expand Down
10 changes: 3 additions & 7 deletions doc/cmd-v1-help/freeze.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ Flags for v1-freeze:
verbosity level is 1)
--dry-run # Do not freeze anything, only print what would
be frozen
--enable-tests # Enable freezing of the dependencies of any
--[enable|disable]-tests # Toggle freezing of the dependencies of any
tests suites in the package description file.
--disable-tests # Disable freezing of the dependencies of any
tests suites in the package description file.
--enable-benchmarks # Enable freezing of the dependencies of any
benchmarks suites in the package description
file.
--disable-benchmarks # Disable freezing of the dependencies of any
--[enable|disable]-benchmarks
# Toggle freezing of the dependencies of any
benchmarks suites in the package description
file.
--solver=SOLVER # Select dependency solver to use (default:
Expand Down
Loading
Loading