1 {-# LANGUAGE DeriveGeneric #-}
2 {-# LANGUAGE LambdaCase #-}
3 {-# LANGUAGE RankNTypes #-}
4 {-# LANGUAGE RecordWildCards #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
7 -----------------------------------------------------------------------------
9 -----------------------------------------------------------------------------
12 -- Module : Distribution.Client.Setup
13 -- Copyright : (c) David Himmelstrup 2005
16 -- Maintainer : lemmih@gmail.com
17 -- Stability : provisional
18 -- Portability : portable
19 module Distribution
.Client
.Setup
26 , CommonSetupFlags
(..)
30 , filterConfigureFlags
35 , defaultConfigExFlags
46 , filterBenchmarkFlags
86 , ActAsSetupFlags
(..)
88 , UserConfigFlags
(..)
100 import Distribution
.Client
.Compat
.Prelude
hiding (get
)
103 import Distribution
.Client
.Types
.AllowNewer
(AllowNewer
(..), AllowOlder
(..), RelaxDeps
(..))
104 import Distribution
.Client
.Types
.Credentials
(Password
(..), Token
(..), Username
(..))
105 import Distribution
.Client
.Types
.Repo
(LocalRepo
(..), RemoteRepo
(..))
106 import Distribution
.Client
.Types
.WriteGhcEnvironmentFilesPolicy
108 import Distribution
.Client
.BuildReports
.Types
111 import Distribution
.Client
.Dependency
.Types
114 import Distribution
.Client
.IndexUtils
.ActiveRepos
117 import Distribution
.Client
.IndexUtils
.IndexState
119 , headTotalIndexState
121 import qualified Distribution
.Client
.Init
.Defaults
as IT
122 import qualified Distribution
.Client
.Init
.Types
as IT
123 import Distribution
.Client
.Targets
127 import Distribution
.Deprecated
.ParseUtils
(parseSpaceList
, parseTokenQ
)
128 import Distribution
.Deprecated
.ReadP
(readP_to_E
)
129 import Distribution
.Utils
.NubList
135 import Distribution
.Solver
.Types
.ConstraintSource
136 import Distribution
.Solver
.Types
.Settings
138 import Distribution
.Client
.GlobalFlags
144 import Distribution
.Client
.ManpageFlags
(ManpageFlags
, defaultManpageFlags
, manpageOptions
)
145 import qualified Distribution
.Compat
.CharParsing
as P
146 import Distribution
.FieldGrammar
.Newtypes
(SpecVersion
(..))
147 import Distribution
.PackageDescription
153 import Distribution
.PackageDescription
.Check
(CheckExplanationIDString
)
154 import Distribution
.Parsec
157 import Distribution
.ReadE
164 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
165 import qualified Distribution
.Simple
.Command
as Command
166 import Distribution
.Simple
.Compiler
(Compiler
, PackageDB
, PackageDBStack
)
167 import Distribution
.Simple
.Configure
168 ( computeEffectiveProfiling
169 , configCompilerAuxEx
170 , interpretPackageDbFlags
172 import Distribution
.Simple
.Flag
182 import Distribution
.Simple
.InstallDirs
185 , combinePathTemplate
189 import Distribution
.Simple
.Program
(ProgramDb
, defaultProgramDb
)
190 import Distribution
.Simple
.Setup
191 ( BenchmarkFlags
(benchmarkCommonFlags
)
195 , CommonSetupFlags
(..)
211 import qualified Distribution
.Simple
.Setup
as Cabal
212 import Distribution
.Simple
.Utils
215 import Distribution
.System
(Platform
)
216 import Distribution
.Types
.GivenComponent
217 ( GivenComponent
(..)
218 , PromisedComponent
(..)
220 import Distribution
.Types
.PackageId
221 import Distribution
.Types
.PackageVersionConstraint
222 ( PackageVersionConstraint
(..)
224 import Distribution
.Types
.UnqualComponentName
225 ( unqualComponentNameToPackageName
227 import Distribution
.Verbosity
233 import Distribution
.Version
239 import Control
.Exception
245 import System
.FilePath
249 globalCommand
:: [Command action
] -> CommandUI GlobalFlags
250 globalCommand commands
=
254 "Command line interface to the Haskell Cabal infrastructure."
255 , commandUsage
= \pname
->
256 "See http://www.haskell.org/cabal/ for more information.\n"
260 ++ " [GLOBAL FLAGS] [COMMAND [FLAGS]]\n"
261 , commandDescription
= Just
$ \pname
->
263 commands
' = commands
++ [commandAddAction helpCommandUI
undefined]
264 cmdDescs
= getNormalCommandDescriptions commands
'
265 -- if new commands are added, we want them to appear even if they
266 -- are not included in the custom listing below. Thus, we calculate
267 -- the `otherCmds` list and append it under the `other` category.
268 -- Alternatively, a new testcase could be added that ensures that
269 -- the set of commands listed here is equal to the set of commands
270 -- that are actually available.
317 , "new-haddock-project"
319 , -- v1 commands, stateful style
337 , -- v2 commands, nix-style
346 , "v2-haddock-project"
353 maxlen
= maximum $ [length name |
(name
, _
) <- cmdDescs
]
354 align str
= str
++ replicate (maxlen
- length str
) ' '
355 startGroup n
= " [" ++ n
++ "]"
357 addCmd n
= case lookup n cmdDescs
of
359 Just d
-> " " ++ align n
++ " " ++ d
363 ( [ startGroup
"global"
364 , addCmd
"user-config"
367 , startGroup
"package database"
372 , startGroup
"initialization and download"
377 , startGroup
"project configuration"
380 , addCmd
"gen-bounds"
384 , startGroup
"project building and installing"
388 , addCmd
"haddock-project"
391 , startGroup
"running and testing"
399 , startGroup
"sanity checks and shipping"
405 , startGroup
"deprecated"
409 , startGroup
"new-style projects (forwards-compatible aliases)"
411 , addCmd
"v2-configure"
417 , addCmd
"v2-haddock"
420 , addCmd
"v2-install"
424 , startGroup
"legacy command aliases"
426 , addCmd
"v1-configure"
432 , addCmd
"v1-haddock"
433 , addCmd
"v1-install"
436 , addCmd
"v1-register"
437 , addCmd
"v1-reconfigure"
444 : [addCmd n | n
<- otherCmds
]
447 ++ "For more information about a command use:\n"
450 ++ " COMMAND --help\n"
455 ++ "To install Cabal packages from hackage use:\n"
458 ++ " install foo [--dry-run]\n"
460 ++ "Occasionally you need to update the list of available packages:\n"
464 , commandNotes
= Nothing
465 , commandDefaultFlags
= mempty
466 , commandOptions
= args
469 args
:: ShowOrParseArgs
-> [OptionField GlobalFlags
]
470 args ShowArgs
= argsShown
471 args ParseArgs
= argsShown
++ argsNotShown
473 -- arguments we want to show in the help
474 argsShown
:: [OptionField GlobalFlags
]
479 "Print version information"
481 (\v flags
-> flags
{globalVersion
= v
})
486 "Print just the version number"
488 (\v flags
-> flags
{globalNumericVersion
= v
})
493 "Set an alternate location for the config file"
495 (\v flags
-> flags
{globalConfigFile
= v
})
500 "Ignore expiry dates on signed metadata (use only in exceptional circumstances)"
502 (\v flags
-> flags
{globalIgnoreExpiry
= v
})
507 "Set a transport for http(s) requests. Accepts 'curl', 'wget', 'powershell', and 'plain-http'. (default: 'curl')"
509 (\v flags
-> flags
{globalHttpTransport
= v
})
510 (reqArgFlag
"HttpTransport")
514 (\v flags
-> flags
{globalNix
= v
})
517 (maybeToFlag
. (readMaybe
=<<))
519 Flag
True -> [Just
"enable"]
520 Flag
False -> [Just
"disable"]
524 ["nix"] -- Must be empty because we need to return PP.empty from viewAsFieldDescr
525 "[DEPRECATED] Nix integration: run commands through nix-shell if a 'shell.nix' file exists (default is False)"
530 "[DEPRECATED] Enable Nix integration: run commands through nix-shell if a 'shell.nix' file exists"
535 "[DEPRECATED] Disable Nix integration"
539 ["store-dir", "storedir"]
540 "The location of the build store"
542 (\v flags
-> flags
{globalStoreDir
= v
})
546 ["active-repositories"]
547 "The active package repositories (set to ':none' to disable all repositories)"
549 (\v flags
-> flags
{globalActiveRepos
= v
})
553 (\err
-> "Error parsing active-repositories: " ++ err
)
554 (toFlag `
fmap` parsec
)
556 (map prettyShow
. flagToList
)
560 -- arguments we don't want shown in the help
561 -- the remote repo flags are not useful compared to the more general "active-repositories" flag.
562 -- the global logs directory was only used in v1, while in v2 we have specific project config logs dirs
563 -- default-user-config is support for a relatively obscure workflow for v1-freeze.
564 argsNotShown
:: [OptionField GlobalFlags
]
569 "The name and url for a remote repository"
571 (\v flags
-> flags
{globalRemoteRepos
= v
})
572 (reqArg
' "NAME:URL" (toNubList
. maybeToList . readRemoteRepo
) (map showRemoteRepo
. fromNubList
))
575 ["local-no-index-repo"]
576 "The name and a path for a local no-index repository"
577 globalLocalNoIndexRepos
578 (\v flags
-> flags
{globalLocalNoIndexRepos
= v
})
579 (reqArg
' "NAME:PATH" (toNubList
. maybeToList . readLocalRepo
) (map showLocalRepo
. fromNubList
))
582 ["remote-repo-cache"]
583 "The location where downloads from all remote repos are cached"
585 (\v flags
-> flags
{globalCacheDir
= v
})
589 ["logs-dir", "logsdir"]
590 "The location to put log files"
592 (\v flags
-> flags
{globalLogsDir
= v
})
596 ["default-user-config"]
597 "Set a location for a cabal.config file for projects without their own cabal.config freeze file."
598 globalConstraintsFile
599 (\v flags
-> flags
{globalConstraintsFile
= v
})
603 -- ------------------------------------------------------------
607 -- ------------------------------------------------------------
609 configureCommand
:: CommandUI ConfigFlags
612 { commandName
= "configure"
613 , commandDefaultFlags
= mempty
614 , commandDescription
= Just
$ \_
->
616 "Configure how the package is built by setting "
617 ++ "package (and other) flags.\n"
619 ++ "The configuration affects several other commands, "
620 ++ "including v1-build, v1-test, v1-bench, v1-run, v1-repl.\n"
621 , commandUsage
= \pname
->
622 "Usage: " ++ pname
++ " v1-configure [FLAGS]\n"
623 , commandNotes
= Just
$ \pname
->
624 (Cabal
.programFlagsDescription defaultProgramDb
++ "\n")
629 ++ " Configure with defaults;\n"
632 ++ " v1-configure --enable-tests -fcustomflag\n"
633 ++ " Configure building package including tests,\n"
634 ++ " with some package-specific flag.\n"
637 c
= Cabal
.configureCommand defaultProgramDb
639 configureOptions
:: ShowOrParseArgs
-> [OptionField ConfigFlags
]
640 configureOptions
= commandOptions configureCommand
642 filterCommonFlags
:: CommonSetupFlags
-> Version
-> CommonSetupFlags
643 filterCommonFlags flags cabalLibVersion
644 -- NB: we expect the latest version to be the most common case,
646 | cabalLibVersion
>= mkVersion
[3, 13, 0] = flags_latest
647 | cabalLibVersion
< mkVersion
[1, 2, 5] = flags_1_2_5
648 | cabalLibVersion
< mkVersion
[2, 1, 0] = flags_2_1_0
649 | cabalLibVersion
< mkVersion
[3, 13, 0] = flags_3_13_0
650 |
otherwise = error "the impossible just happened" -- see first guard
655 { -- Cabal < 3.13 does not support the --working-dir flag.
656 setupWorkingDir
= NoFlag
657 , -- Or the --keep-temp-files flag.
658 setupKeepTempFiles
= NoFlag
662 { -- Cabal < 2.1 doesn't know about -v +timestamp modifier
663 setupVerbosity
= fmap verboseNoTimestamp
(setupVerbosity flags_3_13_0
)
667 { -- Cabal < 1.25 doesn't have extended verbosity syntax
669 fmap verboseNoFlags
(setupVerbosity flags_2_1_0
)
672 -- | Given some 'ConfigFlags' for the version of Cabal that
673 -- cabal-install was built with, and a target older 'Version' of
674 -- Cabal that we want to pass these flags to, convert the
675 -- flags into a form that will be accepted by the older
676 -- Setup script. Generally speaking, this just means filtering
677 -- out flags that the old Cabal library doesn't understand, but
678 -- in some cases it may also mean "emulating" a feature using
679 -- some more legacy flags.
680 filterConfigureFlags
:: ConfigFlags
-> Version
-> ConfigFlags
681 filterConfigureFlags flags cabalLibVersion
=
682 let flags
' = filterConfigureFlags
' flags cabalLibVersion
684 { configCommonFlags
=
685 filterCommonFlags
(configCommonFlags flags
') cabalLibVersion
688 filterConfigureFlags
' :: ConfigFlags
-> Version
-> ConfigFlags
689 filterConfigureFlags
' flags cabalLibVersion
690 -- NB: we expect the latest version to be the most common case,
692 | cabalLibVersion
>= mkVersion
[3, 13, 0] = flags_latest
693 -- The naming convention is that flags_version gives flags with
694 -- all flags *introduced* in version eliminated.
695 -- It is NOT the latest version of Cabal library that
696 -- these flags work for; version of introduction is a more
698 | cabalLibVersion
< mkVersion
[1, 3, 10] = flags_1_3_10
699 | cabalLibVersion
< mkVersion
[1, 10, 0] = flags_1_10_0
700 | cabalLibVersion
< mkVersion
[1, 12, 0] = flags_1_12_0
701 | cabalLibVersion
< mkVersion
[1, 14, 0] = flags_1_14_0
702 | cabalLibVersion
< mkVersion
[1, 18, 0] = flags_1_18_0
703 | cabalLibVersion
< mkVersion
[1, 19, 1] = flags_1_19_1
704 | cabalLibVersion
< mkVersion
[1, 19, 2] = flags_1_19_2
705 | cabalLibVersion
< mkVersion
[1, 21, 1] = flags_1_21_1
706 | cabalLibVersion
< mkVersion
[1, 22, 0] = flags_1_22_0
707 | cabalLibVersion
< mkVersion
[1, 22, 1] = flags_1_22_1
708 | cabalLibVersion
< mkVersion
[1, 23, 0] = flags_1_23_0
709 | cabalLibVersion
< mkVersion
[1, 25, 0] = flags_1_25_0
710 | cabalLibVersion
< mkVersion
[2, 1, 0] = flags_2_1_0
711 | cabalLibVersion
< mkVersion
[2, 5, 0] = flags_2_5_0
712 | cabalLibVersion
< mkVersion
[3, 7, 0] = flags_3_7_0
713 | cabalLibVersion
< mkVersion
[3, 11, 0] = flags_3_11_0
714 | cabalLibVersion
< mkVersion
[3, 13, 0] = flags_3_13_0
715 |
otherwise = error "the impossible just happened" -- see first guard
719 { -- Cabal >= 1.19.1 uses '--dependency' and does not need '--constraint'.
720 -- Note: this is not in the wrong place. configConstraints gets
721 -- repopulated in flags_1_19_1 but it needs to be set to empty for
722 -- newer versions first.
723 configConstraints
= []
727 let scrubVersion pc
=
729 { promisedComponentPackage
=
730 (promisedComponentPackage pc
){pkgVersion
= nullVersion
}
732 in -- Earlier Cabal versions don't understand about ..
734 { -- Building profiled shared libraries
735 configProfShared
= NoFlag
736 , configIgnoreBuildTools
= NoFlag
737 , -- Older versions of Cabal don't include the package version in the
738 -- --promised-dependency flag, by setting the version to nullVersion,
739 -- it won't be printed.
740 configPromisedDependencies
=
741 map scrubVersion
(configPromisedDependencies flags
)
746 { -- It's too late to convert configPromisedDependencies to anything
747 -- meaningful, so we just assert that it's empty.
748 -- We add a Cabal>=3.11 constraint before solving when multi-repl is
749 -- enabled, so this should never trigger.
750 configPromisedDependencies
= assert
(null $ configPromisedDependencies flags
) []
751 , -- Cabal < 3.11 does not understand '--coverage-for', which is OK
752 -- because previous versions of Cabal using coverage implied
753 -- whole-package builds (cuz_coverage), and determine the path to
754 -- libraries mix dirs from the testsuite root with a small hack.
755 configCoverageFor
= NoFlag
760 { -- Cabal < 3.7 does not know about --extra-lib-dirs-static
761 configExtraLibDirsStatic
= []
762 , -- Cabal < 3.7 does not understand '--enable-build-info' or '--disable-build-info'
763 configDumpBuildInfo
= NoFlag
768 { -- Cabal < 2.5 does not understand --dependency=pkg:component=cid
769 -- (public sublibraries), so we convert it to the legacy
770 -- --dependency=pkg_or_internal_component=cid
772 let convertToLegacyInternalDep
(GivenComponent _
(LSubLibName cn
) cid
) =
775 (unqualComponentNameToPackageName cn
)
778 convertToLegacyInternalDep
(GivenComponent pn LMainLibName cid
) =
779 Just
$ GivenComponent pn LMainLibName cid
780 in catMaybes $ convertToLegacyInternalDep
<$> configDependencies flags
781 , -- Cabal < 2.5 doesn't know about '--allow-depending-on-private-libs'.
782 configAllowDependingOnPrivateLibs
= NoFlag
783 , -- Cabal < 2.5 doesn't know about '--enable/disable-executable-static'.
784 configFullyStaticExe
= NoFlag
789 { -- Cabal < 2.1 doesn't know about --<enable|disable>-static
790 configStaticLib
= NoFlag
791 , configSplitSections
= NoFlag
796 { -- Cabal < 1.25.0 doesn't know about --dynlibdir.
797 configInstallDirs
= configInstallDirs_1_25_0
798 , -- Cabal < 1.25 doesn't support --deterministic
799 configDeterministic
= mempty
801 configInstallDirs_1_25_0
=
802 let dirs
= configInstallDirs flags
805 , libexecsubdir
= NoFlag
809 <$> flagToMaybe
(libexecdir dirs
)
810 <*> flagToMaybe
(libexecsubdir dirs
)
812 -- Cabal < 1.23 doesn't know about '--profiling-detail'.
813 -- Cabal < 1.23 has a hacked up version of 'enable-profiling'
814 -- which we shouldn't use.
815 (tryLibProfiling
, _tryLibProfilingShared
, tryExeProfiling
) = computeEffectiveProfiling flags
818 { configProfDetail
= NoFlag
819 , configProfLibDetail
= NoFlag
820 , configIPID
= NoFlag
821 , configProf
= NoFlag
822 , configProfExe
= Flag tryExeProfiling
823 , configProfLib
= Flag tryLibProfiling
826 -- Cabal == 1.22.0.* had a discontinuity (see #5946 or e9a8d48a3adce34d)
827 -- due to temporary amnesia of the --*-executable-profiling flags
830 { configDebugInfo
= NoFlag
831 , configProfExe
= NoFlag
834 -- Cabal < 1.22 doesn't know about '--disable-debug-info'.
835 flags_1_22_0
= flags_1_23_0
{configDebugInfo
= NoFlag
}
837 -- Cabal < 1.21.1 doesn't know about 'disable-relocatable'
838 -- Cabal < 1.21.1 doesn't know about 'enable-profiling'
839 -- (but we already dealt with it in flags_1_23_0)
842 { configRelocatable
= NoFlag
843 , configCoverage
= NoFlag
844 , configLibCoverage
= configCoverage flags
846 -- Cabal < 1.19.2 doesn't know about '--exact-configuration' and
847 -- '--enable-library-stripping'.
850 { configExactConfiguration
= NoFlag
851 , configStripLibs
= NoFlag
853 -- Cabal < 1.19.1 uses '--constraint' instead of '--dependency'.
856 { configDependencies
= []
857 , configConstraints
= configConstraints flags
859 -- Cabal < 1.18.0 doesn't know about --extra-prog-path and --sysconfdir.
862 { configProgramPathExtra
= toNubList
[]
863 , configInstallDirs
= configInstallDirs_1_18_0
865 configInstallDirs_1_18_0
= (configInstallDirs flags_1_19_1
){sysconfdir
= NoFlag
}
866 -- Cabal < 1.14.0 doesn't know about '--disable-benchmarks'.
867 flags_1_14_0
= flags_1_18_0
{configBenchmarks
= NoFlag
}
868 -- Cabal < 1.12.0 doesn't know about '--enable/disable-executable-dynamic'
869 -- and '--enable/disable-library-coverage'.
872 { configLibCoverage
= NoFlag
873 , configDynExe
= NoFlag
875 -- Cabal < 1.10.0 doesn't know about '--disable-tests'.
876 flags_1_10_0
= flags_1_12_0
{configTests
= NoFlag
}
877 -- Cabal < 1.3.10 does not grok the '--constraints' flag.
878 flags_1_3_10
= flags_1_10_0
{configConstraints
= []}
880 -- | Get the package database settings from 'ConfigFlags', accounting for
881 -- @--package-db@ and @--user@ flags.
882 configPackageDB
' :: ConfigFlags
-> PackageDBStack
883 configPackageDB
' cfg
=
884 interpretPackageDbFlags userInstall
(configPackageDBs cfg
)
886 userInstall
= Cabal
.fromFlagOrDefault
True (configUserInstall cfg
)
888 -- | Configure the compiler, but reduce verbosity during this step.
889 configCompilerAux
' :: ConfigFlags
-> IO (Compiler
, Platform
, ProgramDb
)
890 configCompilerAux
' configFlags
= do
891 let commonFlags
= configCommonFlags configFlags
894 { -- FIXME: make configCompilerAux use a sensible verbosity
897 { setupVerbosity
= fmap lessVerbose
(setupVerbosity commonFlags
)
901 -- ------------------------------------------------------------
903 -- * Config extra flags
905 -- ------------------------------------------------------------
907 -- | cabal configure takes some extra flags beyond runghc Setup configure
908 data ConfigExFlags
= ConfigExFlags
909 { configCabalVersion
:: Flag Version
910 , configAppend
:: Flag
Bool
911 , configBackup
:: Flag
Bool
912 , configExConstraints
:: [(UserConstraint
, ConstraintSource
)]
913 , configPreferences
:: [PackageVersionConstraint
]
914 , configSolver
:: Flag PreSolver
915 , configAllowNewer
:: Maybe AllowNewer
916 , configAllowOlder
:: Maybe AllowOlder
917 , configWriteGhcEnvironmentFilesPolicy
918 :: Flag WriteGhcEnvironmentFilesPolicy
920 deriving (Eq
, Show, Generic
)
922 defaultConfigExFlags
:: ConfigExFlags
923 defaultConfigExFlags
= mempty
{configSolver
= Flag defaultSolver
}
925 configureExCommand
:: CommandUI
(ConfigFlags
, ConfigExFlags
)
928 { commandDefaultFlags
= (mempty
, defaultConfigExFlags
)
929 , commandOptions
= \showOrParseArgs
->
934 ( (`
notElem`
["constraint", "dependency", "promised-dependency", "exact-configuration"])
937 $ configureOptions showOrParseArgs
942 (configureExOptions showOrParseArgs ConstraintSourceCommandlineFlag
)
945 setFst a
(_
, b
) = (a
, b
)
946 setSnd b
(a
, _
) = (a
, b
)
951 -> [OptionField ConfigExFlags
]
952 configureExOptions _showOrParseArgs src
=
955 ["cabal-lib-version"]
956 ( "Select which version of the Cabal lib to use to build packages "
957 ++ "(useful for testing)."
960 (\v flags
-> flags
{configCabalVersion
= v
})
964 ("Cannot parse cabal lib version: " ++)
967 (map prettyShow
. flagToList
)
972 "appending the new config to the old config file"
974 (\v flags
-> flags
{configAppend
= v
})
979 "the backup of the config file before any alterations"
981 (\v flags
-> flags
{configBackup
= v
})
986 "Specify constraints on a package (version, installed/source, flags)"
988 (\v flags
-> flags
{configExConstraints
= v
})
991 ((\x
-> [(x
, src
)]) `
fmap` ReadE readUserConstraint
)
992 (map $ prettyShow
. fst)
997 "Specify preferences (soft constraints) on the version of a package"
999 (\v flags
-> flags
{configPreferences
= v
})
1003 (const "dependency expected")
1004 (fmap (\x
-> [x
]) parsec
)
1008 , optionSolver configSolver
(\v flags
-> flags
{configSolver
= v
})
1012 ("Ignore lower bounds in all dependencies or DEPS")
1013 (fmap unAllowOlder
. configAllowOlder
)
1014 (\v flags
-> flags
{configAllowOlder
= fmap AllowOlder v
})
1017 (parsecToReadEErr unexpectMsgString relaxDepsParser
)
1018 (show RelaxDepsAll
, Just RelaxDepsAll
)
1024 ("Ignore upper bounds in all dependencies or DEPS")
1025 (fmap unAllowNewer
. configAllowNewer
)
1026 (\v flags
-> flags
{configAllowNewer
= fmap AllowNewer v
})
1029 (parsecToReadEErr unexpectMsgString relaxDepsParser
)
1030 (show RelaxDepsAll
, Just RelaxDepsAll
)
1035 ["write-ghc-environment-files"]
1036 ( "Whether to create a .ghc.environment file after a successful build"
1037 ++ " (v2-build only)"
1039 configWriteGhcEnvironmentFilesPolicy
1040 (\v flags
-> flags
{configWriteGhcEnvironmentFilesPolicy
= v
})
1042 "always|never|ghc8.4.4+"
1043 writeGhcEnvironmentFilesPolicyParser
1044 writeGhcEnvironmentFilesPolicyPrinter
1048 writeGhcEnvironmentFilesPolicyParser
:: ReadE
(Flag WriteGhcEnvironmentFilesPolicy
)
1049 writeGhcEnvironmentFilesPolicyParser
= ReadE
$ \case
1050 "always" -> Right
$ Flag AlwaysWriteGhcEnvironmentFiles
1051 "never" -> Right
$ Flag NeverWriteGhcEnvironmentFiles
1052 "ghc8.4.4+" -> Right
$ Flag WriteGhcEnvironmentFilesOnlyForGhc844AndNewer
1055 "Cannot parse the GHC environment file write policy '"
1059 writeGhcEnvironmentFilesPolicyPrinter
1060 :: Flag WriteGhcEnvironmentFilesPolicy
-> [String]
1061 writeGhcEnvironmentFilesPolicyPrinter
= \case
1062 (Flag AlwaysWriteGhcEnvironmentFiles
) -> ["always"]
1063 (Flag NeverWriteGhcEnvironmentFiles
) -> ["never"]
1064 (Flag WriteGhcEnvironmentFilesOnlyForGhc844AndNewer
) -> ["ghc8.4.4+"]
1067 relaxDepsParser
:: CabalParsing m
=> m
(Maybe RelaxDeps
)
1068 relaxDepsParser
= do
1069 rs
<- P
.sepBy parsec
(P
.char
',')
1073 "empty argument list is not allowed. "
1074 ++ "Note: use --allow-newer without the equals sign to permit all "
1075 ++ "packages to use newer versions."
1076 else return . Just
. RelaxDepsSome
. toList
$ rs
1078 relaxDepsPrinter
:: (Maybe RelaxDeps
) -> [Maybe String]
1079 relaxDepsPrinter Nothing
= []
1080 relaxDepsPrinter
(Just RelaxDepsAll
) = [Nothing
]
1081 relaxDepsPrinter
(Just
(RelaxDepsSome pkgs
)) = map (Just
. prettyShow
) $ pkgs
1083 instance Monoid ConfigExFlags
where
1087 instance Semigroup ConfigExFlags
where
1090 reconfigureCommand
:: CommandUI
(ConfigFlags
, ConfigExFlags
)
1091 reconfigureCommand
=
1093 { commandName
= "reconfigure"
1094 , commandSynopsis
= "Reconfigure the package if necessary."
1095 , commandDescription
= Just
$ \pname
->
1097 "Run `configure` with the most recently used flags, or append FLAGS "
1098 ++ "to the most recently used configuration. "
1099 ++ "Accepts the same flags as `"
1101 ++ " v1-configure'. "
1102 ++ "If the package has never been configured, the default flags are "
1104 , commandNotes
= Just
$ \pname
->
1108 ++ " v1-reconfigure\n"
1109 ++ " Configure with the most recently used flags.\n"
1112 ++ " v1-reconfigure -w PATH\n"
1113 ++ " Reconfigure with the most recently used flags,\n"
1114 ++ " but use the compiler at PATH.\n\n"
1115 , commandUsage
= usageAlternatives
"v1-reconfigure" ["[FLAGS]"]
1116 , commandDefaultFlags
= mempty
1119 -- ------------------------------------------------------------
1123 -- ------------------------------------------------------------
1125 buildCommand
:: CommandUI BuildFlags
1128 { commandName
= "build"
1129 , commandDescription
= Just
$ \_
->
1131 "Components encompass executables, tests, and benchmarks.\n"
1133 ++ "Affected by configuration options, see `v1-configure`.\n"
1134 , commandDefaultFlags
= commandDefaultFlags parent
1136 usageAlternatives
"v1-build" $
1137 ["[FLAGS]", "COMPONENTS [FLAGS]"]
1138 , commandOptions
= commandOptions parent
1139 , commandNotes
= Just
$ \pname
->
1144 ++ " All the components in the package\n"
1148 ++ " A component (i.e. lib, exe, test suite)\n\n"
1149 ++ Cabal
.programFlagsDescription defaultProgramDb
1152 parent
= Cabal
.buildCommand defaultProgramDb
1154 -- | Given some 'BuildFlags' for the version of @Cabal@ that
1155 -- @cabal-install@ was built with, and a target older 'Version' of
1156 -- @Cabal@ that we want to pass these flags to, convert the
1157 -- flags into a form that will be accepted by the older
1158 -- @Setup@ script. Generally speaking, this just means filtering
1159 -- out flags that the old @Cabal@ library doesn't understand, but
1160 -- in some cases it may also mean "emulating" a feature using
1161 -- some more legacy flags.
1162 filterBuildFlags
:: BuildFlags
-> Version
-> BuildFlags
1163 filterBuildFlags flags cabalLibVersion
=
1165 { buildCommonFlags
=
1166 filterCommonFlags
(buildCommonFlags flags
) cabalLibVersion
1169 -- ------------------------------------------------------------
1173 -- ------------------------------------------------------------
1175 -- | Given some 'TestFlags' for the version of Cabal that
1176 -- cabal-install was built with, and a target older 'Version' of
1177 -- Cabal that we want to pass these flags to, convert the
1178 -- flags into a form that will be accepted by the older
1179 -- Setup script. Generally speaking, this just means filtering
1180 -- out flags that the old Cabal library doesn't understand, but
1181 -- in some cases it may also mean "emulating" a feature using
1182 -- some more legacy flags.
1183 filterTestFlags
:: TestFlags
-> Version
-> TestFlags
1184 filterTestFlags flags cabalLibVersion
=
1185 let flags
' = filterTestFlags
' flags cabalLibVersion
1188 filterCommonFlags
(testCommonFlags flags
') cabalLibVersion
1191 filterTestFlags
' :: TestFlags
-> Version
-> TestFlags
1192 filterTestFlags
' flags cabalLibVersion
1193 -- NB: we expect the latest version to be the most common case,
1194 -- so test it first.
1195 | cabalLibVersion
>= mkVersion
[3, 0, 0] = flags_latest
1196 -- The naming convention is that flags_version gives flags with
1197 -- all flags *introduced* in version eliminated.
1198 -- It is NOT the latest version of Cabal library that
1199 -- these flags work for; version of introduction is a more
1201 | cabalLibVersion
< mkVersion
[3, 0, 0] = flags_3_0_0
1202 |
otherwise = error "the impossible just happened" -- see first guard
1204 flags_latest
= flags
1207 { -- Cabal < 3.0 doesn't know about --test-wrapper
1208 Cabal
.testWrapper
= NoFlag
1211 -- ------------------------------------------------------------
1215 -- ------------------------------------------------------------
1217 replCommand
:: CommandUI ReplFlags
1220 { commandName
= "repl"
1221 , commandDescription
= Just
$ \pname
->
1223 "If the current directory contains no package, ignores COMPONENT "
1224 ++ "parameters and opens an interactive interpreter session;\n"
1226 ++ "Otherwise, (re)configures with the given or default flags, and "
1227 ++ "loads the interpreter with the relevant modules. For executables, "
1228 ++ "tests and benchmarks, loads the main module (and its "
1229 ++ "dependencies); for libraries all exposed/other modules.\n"
1231 ++ "The default component is the library itself, or the executable "
1232 ++ "if that is the only component.\n"
1234 ++ "Support for loading specific modules is planned but not "
1235 ++ "implemented yet. For certain scenarios, `"
1237 ++ " v1-exec -- ghci :l Foo` may be used instead. Note that `v1-exec` will "
1238 ++ "not (re)configure and you will have to specify the location of "
1239 ++ "other modules, if required.\n"
1240 , commandUsage
= \pname
-> "Usage: " ++ pname
++ " v1-repl [COMPONENT] [FLAGS]\n"
1241 , commandDefaultFlags
= commandDefaultFlags parent
1242 , commandOptions
= commandOptions parent
1243 , commandNotes
= Just
$ \pname
->
1248 ++ " The first component in the package\n"
1252 ++ " A named component (i.e. lib, exe, test suite)\n"
1255 ++ " v1-repl --ghc-options=\"-lstdc++\""
1256 ++ " Specifying flags for interpreter\n"
1259 parent
= Cabal
.replCommand defaultProgramDb
1261 -- | Given some 'ReplFlags' for the version of @Cabal@ that
1262 -- @cabal-install@ was built with, and a target older 'Version' of
1263 -- @Cabal@ that we want to pass these flags to, convert the
1264 -- flags into a form that will be accepted by the older
1265 -- @Setup@ script. Generally speaking, this just means filtering
1266 -- out flags that the old @Cabal@ library doesn't understand, but
1267 -- in some cases it may also mean "emulating" a feature using
1268 -- some more legacy flags.
1269 filterReplFlags
:: ReplFlags
-> Version
-> ReplFlags
1270 filterReplFlags flags cabalLibVersion
=
1273 (filterCommonFlags
(replCommonFlags flags
) cabalLibVersion
)
1274 { -- `cabal repl` knew about `--keep-temp-files` before other commands did.
1275 setupKeepTempFiles
= setupKeepTempFiles
(replCommonFlags flags
)
1279 -- ------------------------------------------------------------
1283 -- ------------------------------------------------------------
1285 testCommand
:: CommandUI
(BuildFlags
, TestFlags
)
1288 { commandName
= "test"
1289 , commandDescription
= Just
$ \pname
->
1291 "If necessary (re)configures with `--enable-tests` flag and builds"
1292 ++ " the test suite.\n"
1294 ++ "Remember that the tests' dependencies must be installed if there"
1295 ++ " are additional ones; e.g. with `"
1297 ++ " v1-install --only-dependencies --enable-tests`.\n"
1299 ++ "By defining UserHooks in a custom Setup.hs, the package can"
1300 ++ " define actions to be executed before and after running tests.\n"
1304 ["[FLAGS]", "TESTCOMPONENTS [FLAGS]"]
1305 , commandDefaultFlags
= (Cabal
.defaultBuildFlags
, commandDefaultFlags parent
)
1311 (Cabal
.buildOptions progDb showOrParseArgs
)
1315 (commandOptions parent showOrParseArgs
)
1319 set1 a
(_
, b
) = (a
, b
)
1321 set2 b
(a
, _
) = (a
, b
)
1323 parent
= Cabal
.testCommand
1324 progDb
= defaultProgramDb
1326 -- ------------------------------------------------------------
1330 -- ------------------------------------------------------------
1332 benchmarkCommand
:: CommandUI
(BuildFlags
, BenchmarkFlags
)
1335 { commandName
= "bench"
1339 ["[FLAGS]", "BENCHCOMPONENTS [FLAGS]"]
1340 , commandDescription
= Just
$ \pname
->
1342 "If necessary (re)configures with `--enable-benchmarks` flag and"
1343 ++ " builds the benchmarks.\n"
1345 ++ "Remember that the benchmarks' dependencies must be installed if"
1346 ++ " there are additional ones; e.g. with `"
1348 ++ " v1-install --only-dependencies --enable-benchmarks`.\n"
1350 ++ "By defining UserHooks in a custom Setup.hs, the package can"
1351 ++ " define actions to be executed before and after running"
1353 , commandDefaultFlags
= (Cabal
.defaultBuildFlags
, commandDefaultFlags parent
)
1359 (Cabal
.buildOptions progDb showOrParseArgs
)
1363 (commandOptions parent showOrParseArgs
)
1367 set1 a
(_
, b
) = (a
, b
)
1369 set2 b
(a
, _
) = (a
, b
)
1371 parent
= Cabal
.benchmarkCommand
1372 progDb
= defaultProgramDb
1374 -- | Given some 'BenchmarkFlags' for the version of @Cabal@ that
1375 -- @cabal-install@ was built with, and a target older 'Version' of
1376 -- @Cabal@ that we want to pass these flags to, convert the
1377 -- flags into a form that will be accepted by the older
1378 -- @Setup@ script. Generally speaking, this just means filtering
1379 -- out flags that the old @Cabal@ library doesn't understand, but
1380 -- in some cases it may also mean "emulating" a feature using
1381 -- some more legacy flags.
1382 filterBenchmarkFlags
:: BenchmarkFlags
-> Version
-> BenchmarkFlags
1383 filterBenchmarkFlags flags cabalLibVersion
=
1385 { benchmarkCommonFlags
=
1386 filterCommonFlags
(benchmarkCommonFlags flags
) cabalLibVersion
1389 -- ------------------------------------------------------------
1393 -- ------------------------------------------------------------
1395 data FetchFlags
= FetchFlags
1396 { -- fetchOutput :: Flag FilePath,
1397 fetchDeps
:: Flag
Bool
1398 , fetchDryRun
:: Flag
Bool
1399 , fetchSolver
:: Flag PreSolver
1400 , fetchMaxBackjumps
:: Flag
Int
1401 , fetchReorderGoals
:: Flag ReorderGoals
1402 , fetchCountConflicts
:: Flag CountConflicts
1403 , fetchFineGrainedConflicts
:: Flag FineGrainedConflicts
1404 , fetchMinimizeConflictSet
:: Flag MinimizeConflictSet
1405 , fetchIndependentGoals
:: Flag IndependentGoals
1406 , fetchPreferOldest
:: Flag PreferOldest
1407 , fetchShadowPkgs
:: Flag ShadowPkgs
1408 , fetchStrongFlags
:: Flag StrongFlags
1409 , fetchAllowBootLibInstalls
:: Flag AllowBootLibInstalls
1410 , fetchOnlyConstrained
:: Flag OnlyConstrained
1411 , fetchTests
:: Flag
Bool
1412 , fetchBenchmarks
:: Flag
Bool
1413 , fetchVerbosity
:: Flag Verbosity
1416 defaultFetchFlags
:: FetchFlags
1419 { -- fetchOutput = mempty,
1420 fetchDeps
= toFlag
True
1421 , fetchDryRun
= toFlag
False
1422 , fetchSolver
= Flag defaultSolver
1423 , fetchMaxBackjumps
= Flag defaultMaxBackjumps
1424 , fetchReorderGoals
= Flag
(ReorderGoals
False)
1425 , fetchCountConflicts
= Flag
(CountConflicts
True)
1426 , fetchFineGrainedConflicts
= Flag
(FineGrainedConflicts
True)
1427 , fetchMinimizeConflictSet
= Flag
(MinimizeConflictSet
False)
1428 , fetchIndependentGoals
= Flag
(IndependentGoals
False)
1429 , fetchPreferOldest
= Flag
(PreferOldest
False)
1430 , fetchShadowPkgs
= Flag
(ShadowPkgs
False)
1431 , fetchStrongFlags
= Flag
(StrongFlags
False)
1432 , fetchAllowBootLibInstalls
= Flag
(AllowBootLibInstalls
False)
1433 , fetchOnlyConstrained
= Flag OnlyConstrainedNone
1434 , fetchTests
= toFlag
False
1435 , fetchBenchmarks
= toFlag
False
1436 , fetchVerbosity
= toFlag normal
1439 fetchCommand
:: CommandUI FetchFlags
1442 { commandName
= "fetch"
1443 , commandSynopsis
= "Downloads packages for later installation."
1447 [ "[FLAGS] PACKAGES"
1449 , commandDescription
= Just
$ \_
->
1450 "Note that it currently is not possible to fetch the dependencies for a\n"
1451 ++ "package in the current directory.\n"
1452 , commandNotes
= Nothing
1453 , commandDefaultFlags
= defaultFetchFlags
1454 , commandOptions
= \showOrParseArgs
->
1455 [ optionVerbosity fetchVerbosity
(\v flags
-> flags
{fetchVerbosity
= v
})
1456 , -- , option "o" ["output"]
1457 -- "Put the package(s) somewhere specific rather than the usual cache."
1458 -- fetchOutput (\v flags -> flags { fetchOutput = v })
1459 -- (reqArgFlag "PATH")
1463 ["dependencies", "deps"]
1464 "Resolve and fetch dependencies (default)"
1466 (\v flags
-> flags
{fetchDeps
= v
})
1470 ["no-dependencies", "no-deps"]
1471 "Ignore dependencies"
1473 (\v flags
-> flags
{fetchDeps
= v
})
1478 "Do not install anything, only print what would be installed."
1480 (\v flags
-> flags
{fetchDryRun
= v
})
1485 "dependency checking and compilation for test suites listed in the package description file."
1487 (\v flags
-> flags
{fetchTests
= v
})
1492 "dependency checking and compilation for benchmarks listed in the package description file."
1494 (\v flags
-> flags
{fetchBenchmarks
= v
})
1497 ++ optionSolver fetchSolver
(\v flags
-> flags
{fetchSolver
= v
})
1501 (\v flags
-> flags
{fetchMaxBackjumps
= v
})
1503 (\v flags
-> flags
{fetchReorderGoals
= v
})
1505 (\v flags
-> flags
{fetchCountConflicts
= v
})
1506 fetchFineGrainedConflicts
1507 (\v flags
-> flags
{fetchFineGrainedConflicts
= v
})
1508 fetchMinimizeConflictSet
1509 (\v flags
-> flags
{fetchMinimizeConflictSet
= v
})
1510 fetchIndependentGoals
1511 (\v flags
-> flags
{fetchIndependentGoals
= v
})
1513 (\v flags
-> flags
{fetchPreferOldest
= v
})
1515 (\v flags
-> flags
{fetchShadowPkgs
= v
})
1517 (\v flags
-> flags
{fetchStrongFlags
= v
})
1518 fetchAllowBootLibInstalls
1519 (\v flags
-> flags
{fetchAllowBootLibInstalls
= v
})
1520 fetchOnlyConstrained
1521 (\v flags
-> flags
{fetchOnlyConstrained
= v
})
1524 -- ------------------------------------------------------------
1528 -- ------------------------------------------------------------
1530 data FreezeFlags
= FreezeFlags
1531 { freezeDryRun
:: Flag
Bool
1532 , freezeTests
:: Flag
Bool
1533 , freezeBenchmarks
:: Flag
Bool
1534 , freezeSolver
:: Flag PreSolver
1535 , freezeMaxBackjumps
:: Flag
Int
1536 , freezeReorderGoals
:: Flag ReorderGoals
1537 , freezeCountConflicts
:: Flag CountConflicts
1538 , freezeFineGrainedConflicts
:: Flag FineGrainedConflicts
1539 , freezeMinimizeConflictSet
:: Flag MinimizeConflictSet
1540 , freezeIndependentGoals
:: Flag IndependentGoals
1541 , freezePreferOldest
:: Flag PreferOldest
1542 , freezeShadowPkgs
:: Flag ShadowPkgs
1543 , freezeStrongFlags
:: Flag StrongFlags
1544 , freezeAllowBootLibInstalls
:: Flag AllowBootLibInstalls
1545 , freezeOnlyConstrained
:: Flag OnlyConstrained
1546 , freezeVerbosity
:: Flag Verbosity
1549 defaultFreezeFlags
:: FreezeFlags
1550 defaultFreezeFlags
=
1552 { freezeDryRun
= toFlag
False
1553 , freezeTests
= toFlag
False
1554 , freezeBenchmarks
= toFlag
False
1555 , freezeSolver
= Flag defaultSolver
1556 , freezeMaxBackjumps
= Flag defaultMaxBackjumps
1557 , freezeReorderGoals
= Flag
(ReorderGoals
False)
1558 , freezeCountConflicts
= Flag
(CountConflicts
True)
1559 , freezeFineGrainedConflicts
= Flag
(FineGrainedConflicts
True)
1560 , freezeMinimizeConflictSet
= Flag
(MinimizeConflictSet
False)
1561 , freezeIndependentGoals
= Flag
(IndependentGoals
False)
1562 , freezePreferOldest
= Flag
(PreferOldest
False)
1563 , freezeShadowPkgs
= Flag
(ShadowPkgs
False)
1564 , freezeStrongFlags
= Flag
(StrongFlags
False)
1565 , freezeAllowBootLibInstalls
= Flag
(AllowBootLibInstalls
False)
1566 , freezeOnlyConstrained
= Flag OnlyConstrainedNone
1567 , freezeVerbosity
= toFlag normal
1570 freezeCommand
:: CommandUI FreezeFlags
1573 { commandName
= "freeze"
1574 , commandSynopsis
= "Freeze dependencies."
1575 , commandDescription
= Just
$ \_
->
1577 "Calculates a valid set of dependencies and their exact versions. "
1578 ++ "If successful, saves the result to the file `cabal.config`.\n"
1580 ++ "The package versions specified in `cabal.config` will be used for "
1581 ++ "any future installs.\n"
1583 ++ "An existing `cabal.config` is ignored and overwritten.\n"
1584 , commandNotes
= Nothing
1585 , commandUsage
= usageFlags
"freeze"
1586 , commandDefaultFlags
= defaultFreezeFlags
1587 , commandOptions
= \showOrParseArgs
->
1590 (\v flags
-> flags
{freezeVerbosity
= v
})
1594 "Do not freeze anything, only print what would be frozen"
1596 (\v flags
-> flags
{freezeDryRun
= v
})
1601 ( "freezing of the dependencies of any tests suites "
1602 ++ "in the package description file."
1605 (\v flags
-> flags
{freezeTests
= v
})
1610 ( "freezing of the dependencies of any benchmarks suites "
1611 ++ "in the package description file."
1614 (\v flags
-> flags
{freezeBenchmarks
= v
})
1619 (\v flags
-> flags
{freezeSolver
= v
})
1623 (\v flags
-> flags
{freezeMaxBackjumps
= v
})
1625 (\v flags
-> flags
{freezeReorderGoals
= v
})
1626 freezeCountConflicts
1627 (\v flags
-> flags
{freezeCountConflicts
= v
})
1628 freezeFineGrainedConflicts
1629 (\v flags
-> flags
{freezeFineGrainedConflicts
= v
})
1630 freezeMinimizeConflictSet
1631 (\v flags
-> flags
{freezeMinimizeConflictSet
= v
})
1632 freezeIndependentGoals
1633 (\v flags
-> flags
{freezeIndependentGoals
= v
})
1635 (\v flags
-> flags
{freezePreferOldest
= v
})
1637 (\v flags
-> flags
{freezeShadowPkgs
= v
})
1639 (\v flags
-> flags
{freezeStrongFlags
= v
})
1640 freezeAllowBootLibInstalls
1641 (\v flags
-> flags
{freezeAllowBootLibInstalls
= v
})
1642 freezeOnlyConstrained
1643 (\v flags
-> flags
{freezeOnlyConstrained
= v
})
1646 -- ------------------------------------------------------------
1648 -- * 'gen-bounds' command
1650 -- ------------------------------------------------------------
1652 genBoundsCommand
:: CommandUI FreezeFlags
1655 { commandName
= "gen-bounds"
1656 , commandSynopsis
= "Generate dependency bounds."
1657 , commandDescription
= Just
$ \_
->
1659 "Generates bounds for all dependencies that do not currently have them. "
1660 ++ "Generated bounds are printed to stdout. "
1661 ++ "You can then paste them into your .cabal file.\n"
1663 , commandNotes
= Nothing
1664 , commandUsage
= usageFlags
"gen-bounds"
1665 , commandDefaultFlags
= defaultFreezeFlags
1666 , commandOptions
= \_
->
1667 [ optionVerbosity freezeVerbosity
(\v flags
-> flags
{freezeVerbosity
= v
})
1671 -- ------------------------------------------------------------
1673 -- ------------------------------------------------------------
1675 data CheckFlags
= CheckFlags
1676 { checkVerbosity
:: Flag Verbosity
1677 , checkIgnore
:: [CheckExplanationIDString
]
1679 deriving (Show, Typeable
)
1681 defaultCheckFlags
:: CheckFlags
1684 { checkVerbosity
= Flag normal
1688 checkCommand
:: CommandUI CheckFlags
1691 { commandName
= "check"
1692 , commandSynopsis
= "Check the package for common mistakes."
1693 , commandDescription
= Just
$ \_
->
1695 "Expects a .cabal package file in the current directory.\n"
1697 ++ "Some checks correspond to the requirements to packages on Hackage. "
1698 ++ "If no `Error` is reported, Hackage should accept the "
1699 ++ "package. If errors are present, `check` exits with 1 and Hackage "
1700 ++ "will refuse the package.\n"
1701 , commandNotes
= Nothing
1702 , commandUsage
= usageFlags
"check"
1703 , commandDefaultFlags
= defaultCheckFlags
1704 , commandOptions
= checkOptions
'
1707 checkOptions
' :: ShowOrParseArgs
-> [OptionField CheckFlags
]
1708 checkOptions
' _showOrParseArgs
=
1711 (\v flags
-> flags
{checkVerbosity
= v
})
1715 "ignore a specific warning (e.g. --ignore=missing-upper-bounds)"
1717 (\v c
-> c
{checkIgnore
= v
++ checkIgnore c
})
1718 (reqArg
' "WARNING" (: []) (const []))
1721 -- ------------------------------------------------------------
1725 -- ------------------------------------------------------------
1727 data UpdateFlags
= UpdateFlags
1728 { updateVerbosity
:: Flag Verbosity
1729 , updateIndexState
:: Flag TotalIndexState
1733 defaultUpdateFlags
:: UpdateFlags
1734 defaultUpdateFlags
=
1736 { updateVerbosity
= toFlag normal
1737 , updateIndexState
= toFlag headTotalIndexState
1740 -- ------------------------------------------------------------
1744 -- ------------------------------------------------------------
1746 cleanCommand
:: CommandUI CleanFlags
1749 { commandUsage
= \pname
->
1750 "Usage: " ++ pname
++ " v1-clean [FLAGS]\n"
1753 formatCommand
:: CommandUI
(Flag Verbosity
)
1756 { commandName
= "format"
1757 , commandSynopsis
= "Reformat the .cabal file using the standard style."
1758 , commandDescription
= Nothing
1759 , commandNotes
= Nothing
1760 , commandUsage
= usageAlternatives
"format" ["[FILE]"]
1761 , commandDefaultFlags
= toFlag normal
1762 , commandOptions
= \_
-> []
1765 manpageCommand
:: CommandUI ManpageFlags
1768 { commandName
= "man"
1769 , commandSynopsis
= "Outputs manpage source."
1770 , commandDescription
= Just
$ \_
->
1771 "Output manpage source to STDOUT.\n"
1772 , commandNotes
= Nothing
1773 , commandUsage
= usageFlags
"man"
1774 , commandDefaultFlags
= defaultManpageFlags
1775 , commandOptions
= manpageOptions
1778 runCommand
:: CommandUI BuildFlags
1781 { commandName
= "run"
1782 , commandSynopsis
= "Builds and runs an executable."
1783 , commandDescription
= Just
$ \pname
->
1785 "Builds and then runs the specified executable. If no executable is "
1786 ++ "specified, but the package contains just one executable, that one "
1787 ++ "is built and executed.\n"
1791 ++ " v1-test --show-details=streaming` to run a "
1792 ++ "test-suite and get its full output.\n"
1793 , commandNotes
= Just
$ \pname
->
1798 ++ " Run the only executable in the current package;\n"
1801 ++ " v1-run foo -- --fooflag\n"
1802 ++ " Works similar to `./foo --fooflag`.\n"
1806 ["[FLAGS] [EXECUTABLE] [-- EXECUTABLE_FLAGS]"]
1807 , commandDefaultFlags
= mempty
1808 , commandOptions
= commandOptions parent
1811 parent
= Cabal
.buildCommand defaultProgramDb
1813 -- ------------------------------------------------------------
1817 -- ------------------------------------------------------------
1819 data ReportFlags
= ReportFlags
1820 { reportToken
:: Flag Token
1821 , reportUsername
:: Flag Username
1822 , reportPassword
:: Flag Password
1823 , reportVerbosity
:: Flag Verbosity
1827 defaultReportFlags
:: ReportFlags
1828 defaultReportFlags
=
1830 { reportToken
= mempty
1831 , reportUsername
= mempty
1832 , reportPassword
= mempty
1833 , reportVerbosity
= toFlag normal
1836 reportCommand
:: CommandUI ReportFlags
1839 { commandName
= "report"
1840 , commandSynopsis
= "Upload build reports to a remote server."
1841 , commandDescription
= Nothing
1842 , commandNotes
= Just
$ \_
->
1843 "You can store your Hackage login in the ~/.config/cabal/config file\n"
1844 ++ "(the %APPDATA%\\cabal\\config file on Windows)\n"
1845 , commandUsage
= usageAlternatives
"report" ["[FLAGS]"]
1846 , commandDefaultFlags
= defaultReportFlags
1847 , commandOptions
= \_
->
1848 [ optionVerbosity reportVerbosity
(\v flags
-> flags
{reportVerbosity
= v
})
1852 "Hackage authentication Token."
1854 (\v flags
-> flags
{reportToken
= v
})
1858 (flagToList
. fmap unToken
)
1865 (\v flags
-> flags
{reportUsername
= v
})
1869 (flagToList
. fmap unUsername
)
1876 (\v flags
-> flags
{reportPassword
= v
})
1880 (flagToList
. fmap unPassword
)
1885 instance Monoid ReportFlags
where
1889 instance Semigroup ReportFlags
where
1892 -- ------------------------------------------------------------
1896 -- ------------------------------------------------------------
1898 data GetFlags
= GetFlags
1899 { getDestDir
:: Flag
FilePath
1900 , getOnlyPkgDescr
:: Flag
Bool
1901 , getPristine
:: Flag
Bool
1902 , getIndexState
:: Flag TotalIndexState
1903 , getActiveRepos
:: Flag ActiveRepos
1904 , getSourceRepository
:: Flag
(Maybe RepoKind
)
1905 , getVerbosity
:: Flag Verbosity
1909 defaultGetFlags
:: GetFlags
1912 { getDestDir
= mempty
1913 , getOnlyPkgDescr
= mempty
1914 , getPristine
= mempty
1915 , getIndexState
= mempty
1916 , getActiveRepos
= mempty
1917 , getSourceRepository
= mempty
1918 , getVerbosity
= toFlag normal
1921 getCommand
:: CommandUI GetFlags
1924 { commandName
= "get"
1925 , commandSynopsis
= "Download/Extract a package's source code (repository)."
1926 , commandDescription
= Just
$ \_
-> wrapText
$ unlines descriptionOfGetCommand
1927 , commandNotes
= Just
$ \pname
-> unlines $ notesOfGetCommand
"get" pname
1928 , commandUsage
= usagePackages
"get"
1929 , commandDefaultFlags
= defaultGetFlags
1930 , commandOptions
= \_
->
1931 [ optionVerbosity getVerbosity
(\v flags
-> flags
{getVerbosity
= v
})
1935 "Where to place the package source, defaults to the current directory."
1937 (\v flags
-> flags
{getDestDir
= v
})
1941 ["source-repository"]
1942 "Copy the package's source repository (ie git clone, darcs get, etc as appropriate)."
1944 (\v flags
-> flags
{getSourceRepository
= v
})
1948 (const "invalid source-repository")
1949 (fmap (toFlag
. Just
) parsec
)
1952 (map (fmap show) . flagToList
)
1957 ( "Use source package index state as it existed at a previous time. "
1958 ++ "Accepts unix-timestamps (e.g. '@1474732068'), ISO8601 UTC timestamps "
1959 ++ "(e.g. '2016-09-24T17:47:48Z'), or 'HEAD' (default: 'HEAD'). "
1960 ++ "This determines which package versions are available as well as "
1961 ++ ".cabal file revision is selected (unless --pristine is used)."
1964 (\v flags
-> flags
{getIndexState
= v
})
1969 "index-state must be a "
1970 ++ "unix-timestamps (e.g. '@1474732068'), "
1971 ++ "a ISO8601 UTC timestamp "
1972 ++ "(e.g. '2016-09-24T17:47:48Z'), or 'HEAD'"
1974 (toFlag `
fmap` parsec
)
1976 (flagToList
. fmap prettyShow
)
1980 ["only-package-description"]
1981 "Unpack only the package description file."
1983 (\v flags
-> flags
{getOnlyPkgDescr
= v
})
1987 ["package-description-only"]
1988 "A synonym for --only-package-description."
1990 (\v flags
-> flags
{getOnlyPkgDescr
= v
})
1995 ( "Unpack the original pristine tarball, rather than updating the "
1996 ++ ".cabal file with the latest revision from the package archive."
1999 (\v flags
-> flags
{getPristine
= v
})
2004 -- | List of lines describing command @get@.
2005 descriptionOfGetCommand
:: [String]
2006 descriptionOfGetCommand
=
2007 [ "Creates a local copy of a package's source code. By default it gets the source"
2008 , "tarball and unpacks it in a local subdirectory. Alternatively, with -s it will"
2009 , "get the code from the source repository specified by the package."
2012 -- | Notes for the command @get@.
2015 -- ^ Either @"get"@ or @"unpack"@.
2017 -- ^ E.g. @"cabal"@.
2020 notesOfGetCommand cmd pname
=
2022 , " " ++ unwords [pname
, cmd
, "hlint"]
2023 , " Download the latest stable version of hlint;"
2024 , " " ++ unwords [pname
, cmd
, "lens --source-repository=head"]
2025 , " Download the source repository of lens (i.e. git clone from github)."
2028 -- 'cabal unpack' is a deprecated alias for 'cabal get'.
2029 unpackCommand
:: CommandUI GetFlags
2032 { commandName
= "unpack"
2033 , commandSynopsis
= synopsis
2034 , commandNotes
= Just
$ \pname
->
2036 notesOfGetCommand
"unpack" pname
2037 , commandUsage
= usagePackages
"unpack"
2040 synopsis
= "Deprecated alias for 'get'."
2042 instance Monoid GetFlags
where
2046 instance Semigroup GetFlags
where
2049 -- ------------------------------------------------------------
2053 -- ------------------------------------------------------------
2055 data ListFlags
= ListFlags
2056 { listInstalled
:: Flag
Bool
2057 , listSimpleOutput
:: Flag
Bool
2058 , listCaseInsensitive
:: Flag
Bool
2059 , listVerbosity
:: Flag Verbosity
2060 , listPackageDBs
:: [Maybe PackageDB
]
2061 , listHcPath
:: Flag
FilePath
2065 defaultListFlags
:: ListFlags
2068 { listInstalled
= Flag
False
2069 , listSimpleOutput
= Flag
False
2070 , listCaseInsensitive
= Flag
True
2071 , listVerbosity
= toFlag normal
2072 , listPackageDBs
= []
2073 , listHcPath
= mempty
2076 listCommand
:: CommandUI ListFlags
2079 { commandName
= "list"
2080 , commandSynopsis
= "List packages matching a search string."
2081 , commandDescription
= Just
$ \_
->
2083 "List all packages, or all packages matching one of the search"
2086 ++ "Use the package database specified with --package-db. "
2087 ++ "If not specified, use the user package database.\n"
2088 , commandNotes
= Just
$ \pname
->
2093 ++ " Will find pandoc, pandoc-citeproc, pandoc-lens, ...\n"
2100 , commandDefaultFlags
= defaultListFlags
2101 , commandOptions
= const listOptions
2104 listOptions
:: [OptionField ListFlags
]
2106 [ optionVerbosity listVerbosity
(\v flags
-> flags
{listVerbosity
= v
})
2110 "Only print installed packages"
2112 (\v flags
-> flags
{listInstalled
= v
})
2117 "Print in a easy-to-parse format"
2119 (\v flags
-> flags
{listSimpleOutput
= v
})
2124 "Ignore case distinctions"
2126 (\v flags
-> flags
{listCaseInsensitive
= v
})
2127 (boolOpt
' (['i
'], ["ignore-case"]) (['I
'], ["strict-case"]))
2131 ( "Append the given package database to the list of package"
2132 ++ " databases used (to satisfy dependencies and register into)."
2133 ++ " May be a specific file, 'global' or 'user'. The initial list"
2134 ++ " is ['global'], ['global', 'user'],"
2135 ++ " depending on context. Use 'clear' to reset the list to empty."
2136 ++ " See the user guide for details."
2139 (\v flags
-> flags
{listPackageDBs
= v
})
2140 (reqArg
' "DB" readPackageDbList showPackageDbList
)
2144 "give the path to a particular compiler"
2146 (\v flags
-> flags
{listHcPath
= v
})
2150 listNeedsCompiler
:: ListFlags
-> Bool
2151 listNeedsCompiler f
=
2152 flagElim
False (const True) (listHcPath f
)
2153 || fromFlagOrDefault
False (listInstalled f
)
2155 instance Monoid ListFlags
where
2159 instance Semigroup ListFlags
where
2162 -- ------------------------------------------------------------
2166 -- ------------------------------------------------------------
2168 data InfoFlags
= InfoFlags
2169 { infoVerbosity
:: Flag Verbosity
2170 , infoPackageDBs
:: [Maybe PackageDB
]
2174 defaultInfoFlags
:: InfoFlags
2177 { infoVerbosity
= toFlag normal
2178 , infoPackageDBs
= []
2181 infoCommand
:: CommandUI InfoFlags
2184 { commandName
= "info"
2185 , commandSynopsis
= "Display detailed information about a particular package."
2186 , commandDescription
= Just
$ \_
->
2188 "Use the package database specified with --package-db. "
2189 ++ "If not specified, use the user package database.\n"
2190 , commandNotes
= Nothing
2191 , commandUsage
= usageAlternatives
"info" ["[FLAGS] PACKAGES"]
2192 , commandDefaultFlags
= defaultInfoFlags
2193 , commandOptions
= \_
->
2194 [ optionVerbosity infoVerbosity
(\v flags
-> flags
{infoVerbosity
= v
})
2198 ( "Append the given package database to the list of package"
2199 ++ " databases used (to satisfy dependencies and register into)."
2200 ++ " May be a specific file, 'global' or 'user'. The initial list"
2201 ++ " is ['global'], ['global', 'user'],"
2202 ++ " depending on context. Use 'clear' to reset the list to empty."
2203 ++ " See the user guide for details."
2206 (\v flags
-> flags
{infoPackageDBs
= v
})
2207 (reqArg
' "DB" readPackageDbList showPackageDbList
)
2211 instance Monoid InfoFlags
where
2215 instance Semigroup InfoFlags
where
2218 -- ------------------------------------------------------------
2222 -- ------------------------------------------------------------
2224 -- | Install takes the same flags as configure along with a few extras.
2225 data InstallFlags
= InstallFlags
2226 { installDocumentation
:: Flag
Bool
2227 , installHaddockIndex
:: Flag PathTemplate
2228 , installDest
:: Flag Cabal
.CopyDest
2229 , installDryRun
:: Flag
Bool
2230 , installOnlyDownload
:: Flag
Bool
2231 , installMaxBackjumps
:: Flag
Int
2232 , installReorderGoals
:: Flag ReorderGoals
2233 , installCountConflicts
:: Flag CountConflicts
2234 , installFineGrainedConflicts
:: Flag FineGrainedConflicts
2235 , installMinimizeConflictSet
:: Flag MinimizeConflictSet
2236 , installIndependentGoals
:: Flag IndependentGoals
2237 , installPreferOldest
:: Flag PreferOldest
2238 , installShadowPkgs
:: Flag ShadowPkgs
2239 , installStrongFlags
:: Flag StrongFlags
2240 , installAllowBootLibInstalls
:: Flag AllowBootLibInstalls
2241 , installOnlyConstrained
:: Flag OnlyConstrained
2242 , installReinstall
:: Flag
Bool
2243 , installAvoidReinstalls
:: Flag AvoidReinstalls
2244 , installOverrideReinstall
:: Flag
Bool
2245 , installUpgradeDeps
:: Flag
Bool
2246 , installOnly
:: Flag
Bool
2247 , installOnlyDeps
:: Flag
Bool
2248 , installIndexState
:: Flag TotalIndexState
2249 , installRootCmd
:: Flag
String
2250 , installSummaryFile
:: NubList PathTemplate
2251 , installLogFile
:: Flag PathTemplate
2252 , installBuildReports
:: Flag ReportLevel
2253 , installReportPlanningFailure
:: Flag
Bool
2254 , -- Note: symlink-bindir is no longer used by v2-install and can be removed
2255 -- when removing v1 commands
2256 installSymlinkBinDir
:: Flag
FilePath
2257 , installPerComponent
:: Flag
Bool
2258 , installNumJobs
:: Flag
(Maybe Int)
2259 , installUseSemaphore
:: Flag
Bool
2260 , installKeepGoing
:: Flag
Bool
2261 , installRunTests
:: Flag
Bool
2262 , installOfflineMode
:: Flag
Bool
2264 deriving (Eq
, Show, Generic
)
2266 instance Binary InstallFlags
2268 defaultInstallFlags
:: InstallFlags
2269 defaultInstallFlags
=
2271 { installDocumentation
= Flag
False
2272 , installHaddockIndex
= Flag docIndexFile
2273 , installDest
= Flag Cabal
.NoCopyDest
2274 , installDryRun
= Flag
False
2275 , installOnlyDownload
= Flag
False
2276 , installMaxBackjumps
= Flag defaultMaxBackjumps
2277 , installReorderGoals
= Flag
(ReorderGoals
False)
2278 , installCountConflicts
= Flag
(CountConflicts
True)
2279 , installFineGrainedConflicts
= Flag
(FineGrainedConflicts
True)
2280 , installMinimizeConflictSet
= Flag
(MinimizeConflictSet
False)
2281 , installIndependentGoals
= Flag
(IndependentGoals
False)
2282 , installPreferOldest
= Flag
(PreferOldest
False)
2283 , installShadowPkgs
= Flag
(ShadowPkgs
False)
2284 , installStrongFlags
= Flag
(StrongFlags
False)
2285 , installAllowBootLibInstalls
= Flag
(AllowBootLibInstalls
False)
2286 , installOnlyConstrained
= Flag OnlyConstrainedNone
2287 , installReinstall
= Flag
False
2288 , installAvoidReinstalls
= Flag
(AvoidReinstalls
False)
2289 , installOverrideReinstall
= Flag
False
2290 , installUpgradeDeps
= Flag
False
2291 , installOnly
= Flag
False
2292 , installOnlyDeps
= Flag
False
2293 , installIndexState
= mempty
2294 , installRootCmd
= mempty
2295 , installSummaryFile
= mempty
2296 , installLogFile
= mempty
2297 , installBuildReports
= Flag NoReports
2298 , installReportPlanningFailure
= Flag
False
2299 , installSymlinkBinDir
= mempty
2300 , installPerComponent
= Flag
True
2301 , installNumJobs
= mempty
2302 , installUseSemaphore
= Flag
False
2303 , installKeepGoing
= Flag
False
2304 , installRunTests
= mempty
2305 , installOfflineMode
= Flag
False
2312 </> "$arch-$os-$compiler"
2316 defaultMaxBackjumps
:: Int
2317 defaultMaxBackjumps
= 4000
2319 defaultSolver
:: PreSolver
2320 defaultSolver
= AlwaysModular
2322 allSolvers
:: String
2323 allSolvers
= intercalate
", " (map prettyShow
([minBound .. maxBound] :: [PreSolver
]))
2336 { commandName
= "install"
2337 , commandSynopsis
= "Install packages."
2342 , "[FLAGS] PACKAGES"
2344 , commandDescription
= Just
$ \_
->
2346 "Installs one or more packages. By default, the installed package"
2347 ++ " will be registered in the user's package database."
2349 ++ "If PACKAGES are specified, downloads and installs those packages."
2350 ++ " Otherwise, install the package in the current directory (and/or its"
2351 ++ " dependencies) (there must be exactly one .cabal file in the current"
2354 ++ "The flags to `v1-install` are saved and"
2355 ++ " affect future commands such as `v1-build` and `v1-repl`. See the help for"
2356 ++ " `v1-configure` for a list of commands being affected.\n"
2358 ++ "Installed executables will by default"
2359 ++ " be put into `~/.local/bin/`."
2360 ++ " If you want installed executable to be available globally, make"
2361 ++ " sure that the PATH environment variable contains that directory.\n"
2363 , commandNotes
= Just
$ \pname
->
2364 ( case commandNotes
$
2365 Cabal
.configureCommand defaultProgramDb
of
2366 Just desc
-> desc pname
++ "\n"
2373 ++ " Package in the current directory\n"
2376 ++ " v1-install foo "
2377 ++ " Package from the hackage server\n"
2380 ++ " v1-install foo-1.0 "
2381 ++ " Specific version of a package\n"
2384 ++ " v1-install 'foo < 2' "
2385 ++ " Constrained package version\n"
2388 ++ " v1-install haddock --bindir=$HOME/hask-bin/ --datadir=$HOME/hask-data/\n"
2390 ++ (map (const ' ') pname
)
2392 ++ " Change installation destination\n"
2393 , commandDefaultFlags
= (mempty
, mempty
, mempty
, mempty
, mempty
, mempty
)
2394 , commandOptions
= \showOrParseArgs
->
2398 -- Note: [Hidden Flags]
2399 -- hide "constraint", "dependency", "promised-dependency" and
2400 -- "exact-configuration" from the configure options.
2405 , "promised-dependency"
2406 , "exact-configuration"
2411 $ configureOptions showOrParseArgs
2413 ++ liftOptions get2 set2
(configureExOptions showOrParseArgs ConstraintSourceCommandlineFlag
)
2417 -- hide "target-package-db" flag from the
2420 ( (`
notElem`
["target-package-db"])
2423 $ installOptions showOrParseArgs
2425 ++ liftOptions get4 set4
(haddockOptions showOrParseArgs
)
2426 ++ liftOptions get5 set5
(testOptions showOrParseArgs
)
2427 ++ liftOptions get6 set6
(benchmarkOptions showOrParseArgs
)
2430 get1
(a
, _
, _
, _
, _
, _
) = a
2431 set1 a
(_
, b
, c
, d
, e
, f
) = (a
, b
, c
, d
, e
, f
)
2432 get2
(_
, b
, _
, _
, _
, _
) = b
2433 set2 b
(a
, _
, c
, d
, e
, f
) = (a
, b
, c
, d
, e
, f
)
2434 get3
(_
, _
, c
, _
, _
, _
) = c
2435 set3 c
(a
, b
, _
, d
, e
, f
) = (a
, b
, c
, d
, e
, f
)
2436 get4
(_
, _
, _
, d
, _
, _
) = d
2437 set4 d
(a
, b
, c
, _
, e
, f
) = (a
, b
, c
, d
, e
, f
)
2438 get5
(_
, _
, _
, _
, e
, _
) = e
2439 set5 e
(a
, b
, c
, d
, _
, f
) = (a
, b
, c
, d
, e
, f
)
2440 get6
(_
, _
, _
, _
, _
, f
) = f
2441 set6 f
(a
, b
, c
, d
, e
, _
) = (a
, b
, c
, d
, e
, f
)
2443 haddockCommand
:: CommandUI HaddockFlags
2445 Cabal
.haddockCommand
2447 usageAlternatives
"v1-haddock" $
2448 ["[FLAGS]", "COMPONENTS [FLAGS]"]
2451 filterHaddockArgs
:: [String] -> Version
-> [String]
2452 filterHaddockArgs args cabalLibVersion
2453 | cabalLibVersion
>= mkVersion
[2, 3, 0] = args_latest
2454 | cabalLibVersion
< mkVersion
[2, 3, 0] = args_2_3_0
2455 |
otherwise = args_latest
2459 -- Cabal < 2.3 doesn't know about per-component haddock
2462 -- | Given some 'HaddockFlags' for the version of @Cabal@ that
2463 -- @cabal-install@ was built with, and a target older 'Version' of
2464 -- @Cabal@ that we want to pass these flags to, convert the
2465 -- flags into a form that will be accepted by the older
2466 -- @Setup@ script. Generally speaking, this just means filtering
2467 -- out flags that the old @Cabal@ library doesn't understand, but
2468 -- in some cases it may also mean "emulating" a feature using
2469 -- some more legacy flags.
2470 filterHaddockFlags
:: HaddockFlags
-> Version
-> HaddockFlags
2471 filterHaddockFlags flags cabalLibVersion
2472 | cabalLibVersion
>= mkVersion
[2, 3, 0] = flags_latest
2473 | cabalLibVersion
< mkVersion
[2, 3, 0] = flags_2_3_0
2474 |
otherwise = flags_latest
2478 { haddockCommonFlags
=
2479 (filterCommonFlags
(haddockCommonFlags flags
) cabalLibVersion
)
2480 { -- `cabal haddock` knew about `--keep-temp-files` before other commands did.
2481 setupKeepTempFiles
= setupKeepTempFiles
(haddockCommonFlags flags
)
2487 { -- Cabal < 2.3 doesn't know about per-component haddock
2488 haddockCommonFlags
=
2489 (haddockCommonFlags flags_latest
)
2494 haddockOptions
:: ShowOrParseArgs
-> [OptionField HaddockFlags
]
2495 haddockOptions showOrParseArgs
=
2497 { optionName
= "haddock-" ++ name
2499 [ fmapOptFlags
(\(_
, lflags
) -> ([], map ("haddock-" ++) lflags
)) descr
2500 | descr
<- optionDescr opt
2503 | opt
<- commandOptions Cabal
.haddockCommand showOrParseArgs
2504 , let name
= optionName opt
2515 , "hyperlink-source"
2518 , "contents-location"
2528 testOptions
:: ShowOrParseArgs
-> [OptionField TestFlags
]
2529 testOptions showOrParseArgs
=
2531 { optionName
= prefixTest name
2533 [ fmapOptFlags
(\(_
, lflags
) -> ([], map prefixTest lflags
)) descr
2534 | descr
<- optionDescr opt
2537 | opt
<- commandOptions Cabal
.testCommand showOrParseArgs
2538 , let name
= optionName opt
2544 , "fail-when-no-test-suites"
2552 |
"test-" `
isPrefixOf` name
= name
2553 |
otherwise = "test-" ++ name
2555 -- | Options for the @bench@ command.
2557 -- Not to be confused with the @benchmarkOptions@ field of the `BenchmarkFlags` record!
2558 benchmarkOptions
:: ShowOrParseArgs
-> [OptionField BenchmarkFlags
]
2559 benchmarkOptions showOrParseArgs
=
2561 { optionName
= prefixBenchmark name
2563 [ fmapOptFlags
(\(_
, lflags
) -> ([], map prefixBenchmark lflags
)) descr
2564 | descr
<- optionDescr opt
2567 | opt
<- commandOptions Cabal
.benchmarkCommand showOrParseArgs
2568 , let name
= optionName opt
2569 , name `
elem`
["benchmark-options", "benchmark-option"]
2572 prefixBenchmark name
2573 |
"benchmark-" `
isPrefixOf` name
= name
2574 |
otherwise = "benchmark-" ++ name
2576 fmapOptFlags
:: (OptFlags
-> OptFlags
) -> OptDescr a
-> OptDescr a
2577 fmapOptFlags modify
(ReqArg d f p r w
) = ReqArg d
(modify f
) p r w
2578 fmapOptFlags modify
(OptArg d f p r i w
) = OptArg d
(modify f
) p r i w
2579 fmapOptFlags modify
(ChoiceOpt xs
) = ChoiceOpt
[(d
, modify f
, i
, w
) |
(d
, f
, i
, w
) <- xs
]
2580 fmapOptFlags modify
(BoolOpt d f1 f2 r w
) = BoolOpt d
(modify f1
) (modify f2
) r w
2582 installOptions
:: ShowOrParseArgs
-> [OptionField InstallFlags
]
2583 installOptions showOrParseArgs
=
2587 "building of documentation"
2588 installDocumentation
2589 (\v flags
-> flags
{installDocumentation
= v
})
2594 "A central index of haddock API documentation (template cannot use $pkgid)"
2596 (\v flags
-> flags
{installHaddockIndex
= v
})
2599 (toFlag
. toPathTemplate
)
2600 (flagToList
. fmap fromPathTemplate
)
2605 "Do not install anything, only print what would be installed."
2607 (\v flags
-> flags
{installDryRun
= v
})
2612 "Do not build anything, only fetch the packages."
2614 (\v flags
-> flags
{installOnlyDownload
= v
})
2618 ["target-package-db"]
2619 "package database to install into. Required when using ${pkgroot} prefix."
2621 (\v flags
-> flags
{installDest
= v
})
2624 (succeedReadE
(Flag
. Cabal
.CopyToDb
))
2625 (\f -> case f
of Flag
(Cabal
.CopyToDb p
) -> [p
]; _
-> [])
2628 ++ optionSolverFlags
2631 (\v flags
-> flags
{installMaxBackjumps
= v
})
2633 (\v flags
-> flags
{installReorderGoals
= v
})
2634 installCountConflicts
2635 (\v flags
-> flags
{installCountConflicts
= v
})
2636 installFineGrainedConflicts
2637 (\v flags
-> flags
{installFineGrainedConflicts
= v
})
2638 installMinimizeConflictSet
2639 (\v flags
-> flags
{installMinimizeConflictSet
= v
})
2640 installIndependentGoals
2641 (\v flags
-> flags
{installIndependentGoals
= v
})
2643 (\v flags
-> flags
{installPreferOldest
= v
})
2645 (\v flags
-> flags
{installShadowPkgs
= v
})
2647 (\v flags
-> flags
{installStrongFlags
= v
})
2648 installAllowBootLibInstalls
2649 (\v flags
-> flags
{installAllowBootLibInstalls
= v
})
2650 installOnlyConstrained
2651 (\v flags
-> flags
{installOnlyConstrained
= v
})
2655 "Install even if it means installing the same version again."
2657 (\v flags
-> flags
{installReinstall
= v
})
2658 (yesNoOpt showOrParseArgs
)
2661 ["avoid-reinstalls"]
2662 "Do not select versions that would destructively overwrite installed packages."
2663 (fmap asBool
. installAvoidReinstalls
)
2664 (\v flags
-> flags
{installAvoidReinstalls
= fmap AvoidReinstalls v
})
2665 (yesNoOpt showOrParseArgs
)
2668 ["force-reinstalls"]
2669 "Reinstall packages even if they will most likely break other installed packages."
2670 installOverrideReinstall
2671 (\v flags
-> flags
{installOverrideReinstall
= v
})
2672 (yesNoOpt showOrParseArgs
)
2675 ["upgrade-dependencies"]
2676 "Pick the latest version for all dependencies, rather than trying to pick an installed version."
2678 (\v flags
-> flags
{installUpgradeDeps
= v
})
2679 (yesNoOpt showOrParseArgs
)
2682 ["only-dependencies"]
2683 "Install only the dependencies necessary to build the given packages"
2685 (\v flags
-> flags
{installOnlyDeps
= v
})
2686 (yesNoOpt showOrParseArgs
)
2689 ["dependencies-only"]
2690 "A synonym for --only-dependencies"
2692 (\v flags
-> flags
{installOnlyDeps
= v
})
2693 (yesNoOpt showOrParseArgs
)
2697 ( "Use source package index state as it existed at a previous time. "
2698 ++ "Accepts unix-timestamps (e.g. '@1474732068'), ISO8601 UTC timestamps "
2699 ++ "(e.g. '2016-09-24T17:47:48Z'), or 'HEAD' (default: 'HEAD')."
2702 (\v flags
-> flags
{installIndexState
= v
})
2707 "index-state must be a "
2708 ++ "unix-timestamps (e.g. '@1474732068'), "
2709 ++ "a ISO8601 UTC timestamp "
2710 ++ "(e.g. '2016-09-24T17:47:48Z'), or 'HEAD'"
2712 (toFlag `
fmap` parsec
)
2714 (flagToList
. fmap prettyShow
)
2719 "(No longer supported, do not use.)"
2721 (\v flags
-> flags
{installRootCmd
= v
})
2722 (reqArg
' "COMMAND" toFlag flagToList
)
2726 "Add symlinks to installed executables into this directory."
2727 installSymlinkBinDir
2728 (\v flags
-> flags
{installSymlinkBinDir
= v
})
2733 "Save build summaries to file (name template can use $pkgid, $compiler, $os, $arch)"
2735 (\v flags
-> flags
{installSummaryFile
= v
})
2736 (reqArg
' "TEMPLATE" (\x
-> toNubList
[toPathTemplate x
]) (map fromPathTemplate
. fromNubList
))
2740 "Log all builds to file (name template can use $pkgid, $compiler, $os, $arch)"
2742 (\v flags
-> flags
{installLogFile
= v
})
2745 (toFlag
. toPathTemplate
)
2746 (flagToList
. fmap fromPathTemplate
)
2750 ["remote-build-reporting"]
2751 "Generate build reports to send to a remote server (none, anonymous or detailed)."
2753 (\v flags
-> flags
{installBuildReports
= v
})
2758 "report level must be 'none', "
2759 ++ "'anonymous' or 'detailed'"
2761 (toFlag `
fmap` parsec
)
2763 (flagToList
. fmap prettyShow
)
2767 ["report-planning-failure"]
2768 "Generate build reports when the dependency solver fails. This is used by the Hackage build bot."
2769 installReportPlanningFailure
2770 (\v flags
-> flags
{installReportPlanningFailure
= v
})
2775 "Per-component builds when possible"
2777 (\v flags
-> flags
{installPerComponent
= v
})
2782 "Run package test suites during installation."
2784 (\v flags
-> flags
{installRunTests
= v
})
2789 "Use a semaphore so GHC can compile components in parallel"
2791 (\v flags
-> flags
{installUseSemaphore
= v
})
2792 (yesNoOpt showOrParseArgs
)
2795 (\v flags
-> flags
{installNumJobs
= v
})
2799 "After a build failure, continue to build other unaffected packages."
2801 (\v flags
-> flags
{installKeepGoing
= v
})
2806 "Don't download packages from the Internet."
2808 (\v flags
-> flags
{installOfflineMode
= v
})
2809 (yesNoOpt showOrParseArgs
)
2811 ++ case showOrParseArgs
of -- TODO: remove when "cabal install"
2817 "Only installs the package in the current directory."
2819 (\v flags
-> flags
{installOnly
= v
})
2825 :: (flags
-> Flag
(Maybe Int))
2826 -> (Flag
(Maybe Int) -> flags
-> flags
)
2827 -> OptionField flags
2828 optionNumJobs get set
=
2832 "Run NUM jobs simultaneously (or '$ncpus' if no NUM is given)."
2837 (fmap Flag numJobsParser
)
2839 (map (Just
. maybe "$ncpus" show) . flagToList
)
2842 numJobsParser
:: ReadE
(Maybe Int)
2843 numJobsParser
= ReadE
$ \s
->
2845 "$ncpus" -> Right Nothing
2846 _
-> case reads s
of
2848 | n
< 1 -> Left
"The number of jobs should be 1 or more."
2849 |
otherwise -> Right
(Just n
)
2850 _
-> Left
"The jobs value should be a number or '$ncpus'"
2852 instance Monoid InstallFlags
where
2856 instance Semigroup InstallFlags
where
2859 -- ------------------------------------------------------------
2863 -- ------------------------------------------------------------
2865 -- | Is this a candidate package or a package to be published?
2866 data IsCandidate
= IsCandidate | IsPublished
2869 data UploadFlags
= UploadFlags
2870 { uploadCandidate
:: Flag IsCandidate
2871 , uploadDoc
:: Flag
Bool
2872 , uploadToken
:: Flag Token
2873 , uploadUsername
:: Flag Username
2874 , uploadPassword
:: Flag Password
2875 , uploadPasswordCmd
:: Flag
[String]
2876 , uploadVerbosity
:: Flag Verbosity
2880 defaultUploadFlags
:: UploadFlags
2881 defaultUploadFlags
=
2883 { uploadCandidate
= toFlag IsCandidate
2884 , uploadDoc
= toFlag
False
2885 , uploadToken
= mempty
2886 , uploadUsername
= mempty
2887 , uploadPassword
= mempty
2888 , uploadPasswordCmd
= mempty
2889 , uploadVerbosity
= toFlag normal
2892 uploadCommand
:: CommandUI UploadFlags
2895 { commandName
= "upload"
2896 , commandSynopsis
= "Uploads source packages or documentation to Hackage."
2897 , commandDescription
= Nothing
2898 , commandNotes
= Just
$ \_
->
2899 "You can store your Hackage login in the ~/.config/cabal/config file\n"
2900 ++ "(the %APPDATA%\\cabal\\config file on Windows)\n"
2901 ++ relevantConfigValuesText
["token", "username", "password", "password-command"]
2902 , commandUsage
= \pname
->
2903 "Usage: " ++ pname
++ " upload [FLAGS] TARFILES\n"
2904 , commandDefaultFlags
= defaultUploadFlags
2905 , commandOptions
= \_
->
2908 (\v flags
-> flags
{uploadVerbosity
= v
})
2912 "Publish the package instead of uploading it as a candidate."
2914 (\v flags
-> flags
{uploadCandidate
= v
})
2915 (noArg
(Flag IsPublished
))
2919 ( "Upload documentation instead of a source package. "
2920 ++ "By default, this uploads documentation for a package candidate. "
2921 ++ "To upload documentation for "
2922 ++ "a published package, combine with --publish."
2925 (\v flags
-> flags
{uploadDoc
= v
})
2930 "Hackage authentication token."
2932 (\v flags
-> flags
{uploadToken
= v
})
2936 (flagToList
. fmap unToken
)
2943 (\v flags
-> flags
{uploadUsername
= v
})
2947 (flagToList
. fmap unUsername
)
2954 (\v flags
-> flags
{uploadPassword
= v
})
2958 (flagToList
. fmap unPassword
)
2962 ["password-command"]
2963 "Command to get Hackage password."
2965 (\v flags
-> flags
{uploadPasswordCmd
= v
})
2969 ("Cannot parse command: " ++)
2970 (Flag
<$> parseSpaceList parseTokenQ
)
2972 (flagElim
[] (pure
. unwords . fmap show))
2977 instance Monoid UploadFlags
where
2981 instance Semigroup UploadFlags
where
2984 -- ------------------------------------------------------------
2988 -- ------------------------------------------------------------
2990 initCommand
:: CommandUI IT
.InitFlags
2993 { commandName
= "init"
2994 , commandSynopsis
= "Create a new cabal package."
2995 , commandDescription
= Just
$ \_
->
2997 "Create a .cabal, CHANGELOG.md, minimal initial Haskell code and optionally a LICENSE file.\n"
2999 ++ "Calling init with no arguments runs interactive mode, "
3000 ++ "which will try to guess as much as possible and prompt you for the rest.\n"
3001 ++ "Non-interactive mode can be invoked by the -n/--non-interactive flag, "
3002 ++ "which will let you specify the options via flags and will use the defaults for the rest.\n"
3003 ++ "It is also possible to call init with a single argument, which denotes the project's desired "
3004 ++ "root directory.\n"
3005 , commandNotes
= Nothing
3006 , commandUsage
= \pname
->
3007 "Usage: " ++ pname
++ " init [PROJECT ROOT] [FLAGS]\n"
3008 , commandDefaultFlags
= IT
.defaultInitFlags
3009 , commandOptions
= initOptions
3012 initOptions
:: ShowOrParseArgs
-> [OptionField IT
.InitFlags
]
3019 (\v flags
-> flags
{IT
.interactive
= v
})
3020 (boolOpt
' (['i
'], ["interactive"]) (['n
'], ["non-interactive"]))
3024 "Do not generate log messages to stdout."
3026 (\v flags
-> flags
{IT
.quiet
= v
})
3031 "Do not generate explanatory comments in the .cabal file."
3033 (\v flags
-> flags
{IT
.noComments
= v
})
3038 "Generate a minimal .cabal file, that is, do not include extra empty fields. Also implies --no-comments."
3040 (\v flags
-> flags
{IT
.minimal
= v
})
3045 "Overwrite any existing .cabal, LICENSE, or Setup.hs files without warning."
3047 (\v flags
-> flags
{IT
.overwrite
= v
})
3051 ["package-dir", "packagedir"]
3052 "Root directory of the package (default = current directory)."
3054 (\v flags
-> flags
{IT
.packageDir
= v
})
3055 (reqArgFlag
"DIRECTORY")
3059 "Name of the Cabal package to create."
3061 (\v flags
-> flags
{IT
.packageName
= v
})
3065 ("Cannot parse package name: " ++)
3066 (toFlag `
fmap` parsec
)
3068 (flagToList
. fmap prettyShow
)
3073 "Initial version of the package."
3075 (\v flags
-> flags
{IT
.version
= v
})
3079 ("Cannot parse package version: " ++)
3080 (toFlag `
fmap` parsec
)
3082 (flagToList
. fmap prettyShow
)
3087 "Version of the Cabal specification."
3089 (\v flags
-> flags
{IT
.cabalVersion
= v
})
3093 ("Cannot parse Cabal specification version: " ++)
3094 (fmap (toFlag
. getSpecVersion
) parsec
)
3096 (flagToList
. fmap (prettyShow
. SpecVersion
))
3103 (\v flags
-> flags
{IT
.license
= v
})
3107 ("Cannot parse license: " ++)
3108 (toFlag `
fmap` parsec
)
3110 (flagToList
. fmap prettyShow
)
3115 "Name of the project's author."
3117 (\v flags
-> flags
{IT
.author
= v
})
3122 "Email address of the maintainer."
3124 (\v flags
-> flags
{IT
.email
= v
})
3125 (reqArgFlag
"EMAIL")
3129 "Project homepage and/or repository."
3131 (\v flags
-> flags
{IT
.homepage
= v
})
3136 "Short project synopsis."
3138 (\v flags
-> flags
{IT
.synopsis
= v
})
3145 (\v flags
-> flags
{IT
.category
= v
})
3146 (reqArgFlag
"CATEGORY")
3149 ["extra-source-file"]
3150 "Extra source file to be distributed with tarball."
3152 (\v flags
-> flags
{IT
.extraSrc
= mergeListFlag
(IT
.extraSrc flags
) v
})
3156 (fromFlagOrDefault
[])
3161 "Extra doc file to be distributed with tarball."
3163 (\v flags
-> flags
{IT
.extraDoc
= mergeListFlag
(IT
.extraDoc flags
) v
})
3164 (reqArg
' "FILE" (Flag
. (: [])) (fromFlagOrDefault
[]))
3167 ["lib", "is-library"]
3170 (\v flags
-> flags
{IT
.packageType
= v
})
3171 (noArg
(Flag IT
.Library
))
3174 ["exe", "is-executable"]
3175 "Build an executable."
3177 (\v flags
-> flags
{IT
.packageType
= v
})
3178 (noArg
(Flag IT
.Executable
))
3181 ["libandexe", "is-libandexe"]
3182 "Build a library and an executable."
3184 (\v flags
-> flags
{IT
.packageType
= v
})
3185 (noArg
(Flag IT
.LibraryAndExecutable
))
3189 "Generate a test suite, standalone or for a library."
3190 IT
.initializeTestSuite
3191 (\v flags
-> flags
{IT
.initializeTestSuite
= v
})
3196 "Directory containing tests."
3199 flags
{IT
.testDirs
= mergeListFlag
(IT
.testDirs flags
) v
}
3204 (fromFlagOrDefault
[])
3209 "Create a simple project with sensible defaults."
3211 (\v flags
-> flags
{IT
.simpleProject
= v
})
3216 "Specify the main module."
3218 (\v flags
-> flags
{IT
.mainIs
= v
})
3223 "Specify the default language."
3225 (\v flags
-> flags
{IT
.language
= v
})
3229 ("Cannot parse language: " ++)
3230 (toFlag `
fmap` parsec
)
3232 (flagToList
. fmap prettyShow
)
3237 "Export a module from the package."
3241 { IT
.exposedModules
=
3242 mergeListFlag
(IT
.exposedModules flags
) v
3248 ("Cannot parse module name: " ++)
3249 (Flag
. (: []) <$> parsec
)
3251 (flagElim
[] (fmap prettyShow
))
3256 "Use a LANGUAGE extension (in the other-extensions field)."
3261 mergeListFlag
(IT
.otherExts flags
) v
3267 ("Cannot parse extension: " ++)
3268 (Flag
. (: []) <$> parsec
)
3270 (flagElim
[] (fmap prettyShow
))
3275 "Package dependencies. Permits comma separated list of dependencies."
3280 mergeListFlag
(IT
.dependencies flags
) v
3285 (fmap Flag dependenciesReadE
)
3286 (fmap prettyShow
. fromFlagOrDefault
[])
3291 "Directory containing package application executable."
3295 { IT
.applicationDirs
=
3296 mergeListFlag
(IT
.applicationDirs flags
) v
3302 (fromFlagOrDefault
[])
3306 ["source-dir", "sourcedir"]
3307 "Directory containing package library source."
3312 mergeListFlag
(IT
.sourceDirs flags
) v
3318 (fromFlagOrDefault
[])
3323 "Required external build tool."
3328 mergeListFlag
(IT
.buildTools flags
) v
3334 (fromFlagOrDefault
[])
3339 "give the path to a particular compiler. For 'init', this flag is used \
3340 \to set the bounds inferred for the 'base' package."
3342 (\v flags
-> flags
{IT
.initHcPath
= v
})
3344 , optionVerbosity IT
.initVerbosity
(\v flags
-> flags
{IT
.initVerbosity
= v
})
3347 dependenciesReadE
:: ReadE
[Dependency
]
3350 ("Cannot parse dependencies: " ++)
3351 (parsecCommaList parsec
)
3353 -- ------------------------------------------------------------
3355 -- * Copy and Register
3357 -- ------------------------------------------------------------
3359 copyCommand
:: CommandUI CopyFlags
3362 { commandNotes
= Just
$ \pname
->
3367 ++ " All the components in the package\n"
3371 ++ " A component (i.e. lib, exe, test suite)"
3373 usageAlternatives
"v1-copy" $
3375 , "COMPONENTS [FLAGS]"
3379 registerCommand
:: CommandUI RegisterFlags
3381 Cabal
.registerCommand
3382 { commandUsage
= \pname
-> "Usage: " ++ pname
++ " v1-register [FLAGS]\n"
3385 -- | Given some 'RegisterFlags' for the version of @Cabal@ that
3386 -- @cabal-install@ was built with, and a target older 'Version' of
3387 -- @Cabal@ that we want to pass these flags to, convert the
3388 -- flags into a form that will be accepted by the older
3389 -- @Setup@ script. Generally speaking, this just means filtering
3390 -- out flags that the old @Cabal@ library doesn't understand, but
3391 -- in some cases it may also mean "emulating" a feature using
3392 -- some more legacy flags.
3393 filterRegisterFlags
:: RegisterFlags
-> Version
-> RegisterFlags
3394 filterRegisterFlags flags cabalLibVersion
=
3396 { registerCommonFlags
=
3397 filterCommonFlags
(registerCommonFlags flags
) cabalLibVersion
3400 -- | Given some 'CopyFlags' for the version of @Cabal@ that
3401 -- @cabal-install@ was built with, and a target older 'Version' of
3402 -- @Cabal@ that we want to pass these flags to, convert the
3403 -- flags into a form that will be accepted by the older
3404 -- @Setup@ script. Generally speaking, this just means filtering
3405 -- out flags that the old @Cabal@ library doesn't understand, but
3406 -- in some cases it may also mean "emulating" a feature using
3407 -- some more legacy flags.
3408 filterCopyFlags
:: CopyFlags
-> Version
-> CopyFlags
3409 filterCopyFlags flags cabalLibVersion
=
3411 { copyCommonFlags
= filterCommonFlags
(copyCommonFlags flags
) cabalLibVersion
3414 -- ------------------------------------------------------------
3416 -- * ActAsSetup flags
3418 -- ------------------------------------------------------------
3420 data ActAsSetupFlags
= ActAsSetupFlags
3421 { actAsSetupBuildType
:: Flag BuildType
3425 defaultActAsSetupFlags
:: ActAsSetupFlags
3426 defaultActAsSetupFlags
=
3428 { actAsSetupBuildType
= toFlag Simple
3431 actAsSetupCommand
:: CommandUI ActAsSetupFlags
3434 { commandName
= "act-as-setup"
3435 , commandSynopsis
= "Run as-if this was a Setup.hs"
3436 , commandDescription
= Nothing
3437 , commandNotes
= Nothing
3438 , commandUsage
= \pname
->
3439 "Usage: " ++ pname
++ " act-as-setup\n"
3440 , commandDefaultFlags
= defaultActAsSetupFlags
3441 , commandOptions
= \_
->
3445 "Use the given build type."
3447 (\v flags
-> flags
{actAsSetupBuildType
= v
})
3451 ("Cannot parse build type: " ++)
3452 (fmap toFlag parsec
)
3454 (map prettyShow
. flagToList
)
3459 instance Monoid ActAsSetupFlags
where
3463 instance Semigroup ActAsSetupFlags
where
3466 -- ------------------------------------------------------------
3468 -- * UserConfig flags
3470 -- ------------------------------------------------------------
3472 data UserConfigFlags
= UserConfigFlags
3473 { userConfigVerbosity
:: Flag Verbosity
3474 , userConfigForce
:: Flag
Bool
3475 , userConfigAppendLines
:: Flag
[String]
3479 instance Monoid UserConfigFlags
where
3482 { userConfigVerbosity
= toFlag normal
3483 , userConfigForce
= toFlag
False
3484 , userConfigAppendLines
= toFlag
[]
3488 instance Semigroup UserConfigFlags
where
3491 userConfigCommand
:: CommandUI UserConfigFlags
3494 { commandName
= "user-config"
3495 , commandSynopsis
= "Display and update the user's global cabal configuration."
3496 , commandDescription
= Just
$ \_
->
3498 "When upgrading cabal, the set of configuration keys and their default"
3499 ++ " values may change. This command provides means to merge the existing"
3500 ++ " config in ~/.config/cabal/config"
3501 ++ " (i.e. all bindings that are actually defined and not commented out)"
3502 ++ " and the default config of the new version.\n"
3504 ++ "init: Creates a new config file at either ~/.config/cabal/config or as"
3505 ++ " specified by --config-file, if given. An existing file won't be "
3506 ++ " overwritten unless -f or --force is given.\n"
3507 ++ "diff: Shows a pseudo-diff of the user's ~/.config/cabal/config file and"
3508 ++ " the default configuration that would be created by cabal if the"
3509 ++ " config file did not exist.\n"
3510 ++ "update: Applies the pseudo-diff to the configuration that would be"
3511 ++ " created by default, and write the result back to ~/.config/cabal/config."
3512 , commandNotes
= Nothing
3513 , commandUsage
= usageAlternatives
"user-config" ["init", "diff", "update"]
3514 , commandDefaultFlags
= mempty
3515 , commandOptions
= \_
->
3516 [ optionVerbosity userConfigVerbosity
(\v flags
-> flags
{userConfigVerbosity
= v
})
3520 "Overwrite the config file if it already exists."
3522 (\v flags
-> flags
{userConfigForce
= v
})
3527 "Additional setting to augment the config file (replacing a previous setting if it existed)."
3528 userConfigAppendLines
3531 { userConfigAppendLines
=
3532 Flag
$ concat (flagToList
(userConfigAppendLines flags
) ++ flagToList v
)
3535 (reqArg
' "CONFIGLINE" (Flag
. (: [])) (fromMaybe [] . flagToMaybe
))
3539 -- ------------------------------------------------------------
3543 -- ------------------------------------------------------------
3547 -> MkOptDescr
(b
-> Flag
String) (Flag
String -> b
-> b
) b
3548 reqArgFlag ad
= reqArg ad
(succeedReadE Flag
) flagToList
3555 liftOptions get set
= map (liftOption get set
)
3557 yesNoOpt
:: ShowOrParseArgs
-> MkOptDescr
(b
-> Flag
Bool) (Flag
Bool -> b
-> b
) b
3558 yesNoOpt ShowArgs sf lf
= trueArg sf lf
3559 yesNoOpt _ sf lf
= Command
.boolOpt
' flagToMaybe Flag
(sf
, lf
) ([], map ("no-" ++) lf
) sf lf
3562 :: (flags
-> Flag PreSolver
)
3563 -> (Flag PreSolver
-> flags
-> flags
)
3564 -> OptionField flags
3565 optionSolver get set
=
3569 ("Select dependency solver to use (default: " ++ prettyShow defaultSolver
++ "). Choices: " ++ allSolvers
++ ".")
3575 (const $ "solver must be one of: " ++ allSolvers
)
3576 (toFlag `
fmap` parsec
)
3578 (flagToList
. fmap prettyShow
)
3583 -> (flags
-> Flag
Int)
3584 -> (Flag
Int -> flags
-> flags
)
3585 -> (flags
-> Flag ReorderGoals
)
3586 -> (Flag ReorderGoals
-> flags
-> flags
)
3587 -> (flags
-> Flag CountConflicts
)
3588 -> (Flag CountConflicts
-> flags
-> flags
)
3589 -> (flags
-> Flag FineGrainedConflicts
)
3590 -> (Flag FineGrainedConflicts
-> flags
-> flags
)
3591 -> (flags
-> Flag MinimizeConflictSet
)
3592 -> (Flag MinimizeConflictSet
-> flags
-> flags
)
3593 -> (flags
-> Flag IndependentGoals
)
3594 -> (Flag IndependentGoals
-> flags
-> flags
)
3595 -> (flags
-> Flag PreferOldest
)
3596 -> (Flag PreferOldest
-> flags
-> flags
)
3597 -> (flags
-> Flag ShadowPkgs
)
3598 -> (Flag ShadowPkgs
-> flags
-> flags
)
3599 -> (flags
-> Flag StrongFlags
)
3600 -> (Flag StrongFlags
-> flags
-> flags
)
3601 -> (flags
-> Flag AllowBootLibInstalls
)
3602 -> (Flag AllowBootLibInstalls
-> flags
-> flags
)
3603 -> (flags
-> Flag OnlyConstrained
)
3604 -> (Flag OnlyConstrained
-> flags
-> flags
)
3605 -> [OptionField flags
]
3633 ("Maximum number of backjumps allowed while solving (default: " ++ show defaultMaxBackjumps
++ "). Use a negative number to enable unlimited backtracking. Use 0 to disable backtracking completely.")
3638 (parsecToReadE
("Cannot parse number: " ++) (fmap toFlag P
.signedIntegral
))
3639 (map show . flagToList
)
3644 "Try to reorder goals according to certain heuristics. Slows things down on average, but may make backtracking faster for some packages."
3645 (fmap asBool
. getrg
)
3646 (setrg
. fmap ReorderGoals
)
3647 (yesNoOpt showOrParseArgs
)
3651 "Try to speed up solving by preferring goals that are involved in a lot of conflicts (default)."
3652 (fmap asBool
. getcc
)
3653 (setcc
. fmap CountConflicts
)
3654 (yesNoOpt showOrParseArgs
)
3657 ["fine-grained-conflicts"]
3658 "Skip a version of a package if it does not resolve the conflicts encountered in the last version, as a solver optimization (default)."
3659 (fmap asBool
. getfgc
)
3660 (setfgc
. fmap FineGrainedConflicts
)
3661 (yesNoOpt showOrParseArgs
)
3664 ["minimize-conflict-set"]
3665 ( "When there is no solution, try to improve the error message by finding "
3666 ++ "a minimal conflict set (default: false). May increase run time "
3669 (fmap asBool
. getmc
)
3670 (setmc
. fmap MinimizeConflictSet
)
3671 (yesNoOpt showOrParseArgs
)
3674 ["independent-goals"]
3675 "Treat several goals on the command line as independent. If several goals depend on the same package, different versions can be chosen."
3676 (fmap asBool
. getig
)
3677 (setig
. fmap IndependentGoals
)
3678 (yesNoOpt showOrParseArgs
)
3682 "Prefer the oldest (instead of the latest) versions of packages available. Useful to determine lower bounds in the build-depends section."
3683 (fmap asBool
. getpo
)
3684 (setpo
. fmap PreferOldest
)
3685 (yesNoOpt showOrParseArgs
)
3688 ["shadow-installed-packages"]
3689 "If multiple package instances of the same version are installed, treat all but one as shadowed."
3690 (fmap asBool
. getsip
)
3691 (setsip
. fmap ShadowPkgs
)
3692 (yesNoOpt showOrParseArgs
)
3696 "Do not defer flag choices (this used to be the default in cabal-install <= 1.20)."
3697 (fmap asBool
. getstrfl
)
3698 (setstrfl
. fmap StrongFlags
)
3699 (yesNoOpt showOrParseArgs
)
3702 ["allow-boot-library-installs"]
3703 "Allow cabal to install base, ghc-prim, integer-simple, integer-gmp, and template-haskell."
3704 (fmap asBool
. getib
)
3705 (setib
. fmap AllowBootLibInstalls
)
3706 (yesNoOpt showOrParseArgs
)
3709 ["reject-unconstrained-dependencies"]
3710 "Require these packages to have constraints on them if they are to be selected (default: none)."
3716 (const "reject-unconstrained-dependencies must be 'none' or 'all'")
3717 (toFlag `
fmap` parsec
)
3719 (flagToList
. fmap prettyShow
)
3723 usagePackages
:: String -> String -> String
3724 usagePackages name pname
=
3725 "Usage: " ++ pname
++ " " ++ name
++ " [PACKAGES]\n"
3727 usageFlags
:: String -> String -> String
3728 usageFlags name pname
=
3729 "Usage: " ++ pname
++ " " ++ name
++ " [FLAGS]\n"
3731 -- ------------------------------------------------------------
3735 -- ------------------------------------------------------------
3737 showRemoteRepo
:: RemoteRepo
-> String
3738 showRemoteRepo
= prettyShow
3740 readRemoteRepo
:: String -> Maybe RemoteRepo
3741 readRemoteRepo
= simpleParsec
3743 showLocalRepo
:: LocalRepo
-> String
3744 showLocalRepo
= prettyShow
3746 readLocalRepo
:: String -> Maybe LocalRepo
3747 readLocalRepo
= simpleParsec
3749 -- ------------------------------------------------------------
3751 -- * Helpers for Documentation
3753 -- ------------------------------------------------------------
3755 relevantConfigValuesText
:: [String] -> String
3756 relevantConfigValuesText vs
=
3757 "Relevant global configuration keys:\n"
3758 ++ concat [" " ++ v
++ "\n" | v
<- vs
]