{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RecordWildCards     #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE DeriveGeneric       #-}
{-# LANGUAGE LambdaCase          #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Distribution.Client.Setup
-- Copyright   :  (c) David Himmelstrup 2005
-- License     :  BSD-like
--
-- Maintainer  :  lemmih@gmail.com
-- Stability   :  provisional
-- Portability :  portable
--
--
-----------------------------------------------------------------------------
module Distribution.Client.Setup
    ( globalCommand, GlobalFlags(..), defaultGlobalFlags
    , RepoContext(..), withRepoContext
    , configureCommand, ConfigFlags(..), configureOptions, filterConfigureFlags
    , configPackageDB', configCompilerAux'
    , configureExCommand, ConfigExFlags(..), defaultConfigExFlags
    , buildCommand, BuildFlags(..)
    , filterTestFlags
    , replCommand, testCommand, benchmarkCommand, testOptions, benchmarkOptions
                        , configureExOptions, reconfigureCommand
    , installCommand, InstallFlags(..), installOptions, defaultInstallFlags
    , filterHaddockArgs, filterHaddockFlags, haddockOptions
    , defaultSolver, defaultMaxBackjumps
    , listCommand, ListFlags(..), listNeedsCompiler
    ,UpdateFlags(..), defaultUpdateFlags
    , infoCommand, InfoFlags(..)
    , fetchCommand, FetchFlags(..)
    , freezeCommand, FreezeFlags(..)
    , genBoundsCommand
    , getCommand, unpackCommand, GetFlags(..)
    , checkCommand
    , formatCommand
    , uploadCommand, UploadFlags(..), IsCandidate(..)
    , reportCommand, ReportFlags(..)
    , runCommand
    , initCommand, initOptions, IT.InitFlags(..)
    , actAsSetupCommand, ActAsSetupFlags(..)
    , userConfigCommand, UserConfigFlags(..)
    , manpageCommand
    , haddockCommand
    , cleanCommand
    , copyCommand
    , registerCommand

    , liftOptions
    , yesNoOpt
    ) where

import Prelude ()
import Distribution.Client.Compat.Prelude hiding (get)

import Distribution.Client.Types.Credentials (Username (..), Password (..))
import Distribution.Client.Types.Repo (RemoteRepo(..), LocalRepo (..))
import Distribution.Client.Types.AllowNewer (AllowNewer(..), AllowOlder(..), RelaxDeps(..))
import Distribution.Client.Types.WriteGhcEnvironmentFilesPolicy

import Distribution.Client.BuildReports.Types
         ( ReportLevel(..) )
import Distribution.Client.Dependency.Types
         ( PreSolver(..) )
import Distribution.Client.IndexUtils.ActiveRepos
         ( ActiveRepos )
import Distribution.Client.IndexUtils.IndexState
         ( TotalIndexState, headTotalIndexState )
import qualified Distribution.Client.Init.Types as IT
import qualified Distribution.Client.Init.Defaults as IT
import Distribution.Client.Targets
         ( UserConstraint, readUserConstraint )
import Distribution.Utils.NubList
         ( NubList, toNubList, fromNubList)

import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.Settings

import Distribution.Simple.Compiler ( Compiler, PackageDB, PackageDBStack )
import Distribution.Simple.Program (ProgramDb, defaultProgramDb)
import Distribution.Simple.Command hiding (boolOpt, boolOpt')
import qualified Distribution.Simple.Command as Command
import Distribution.Simple.Configure
       ( configCompilerAuxEx, interpretPackageDbFlags, computeEffectiveProfiling )
import qualified Distribution.Simple.Setup as Cabal
import Distribution.Simple.Flag
         ( Flag(..), toFlag, flagToMaybe, flagToList, maybeToFlag
         , flagElim, fromFlagOrDefault
         )
import Distribution.Simple.Setup
         ( ConfigFlags(..), BuildFlags(..), ReplFlags
         , TestFlags, BenchmarkFlags
         , HaddockFlags(..)
         , CleanFlags(..)
         , CopyFlags(..), RegisterFlags(..)
         , readPackageDbList, showPackageDbList
         , BooleanFlag(..), optionVerbosity
         , boolOpt, boolOpt', trueArg, falseArg
         , optionNumJobs )
import Distribution.Simple.InstallDirs
         ( PathTemplate, InstallDirs(..)
         , toPathTemplate, fromPathTemplate, combinePathTemplate )
import Distribution.Version
         ( Version, mkVersion )
import Distribution.Types.GivenComponent
         ( GivenComponent(..) )
import Distribution.Types.PackageVersionConstraint
         ( PackageVersionConstraint(..) )
import Distribution.Types.UnqualComponentName
         ( unqualComponentNameToPackageName )
import Distribution.PackageDescription
         ( BuildType(..), RepoKind(..), LibraryName(..) )
import Distribution.System ( Platform )
import Distribution.ReadE
         ( ReadE(..), succeedReadE, parsecToReadE, parsecToReadEErr, unexpectMsgString )
import qualified Distribution.Compat.CharParsing as P
import Distribution.Verbosity
         ( lessVerbose, normal, verboseNoFlags, verboseNoTimestamp )
import Distribution.Simple.Utils
         ( wrapText )
import Distribution.Client.GlobalFlags
         ( GlobalFlags(..), defaultGlobalFlags
         , RepoContext(..), withRepoContext
         )
import Distribution.Client.ManpageFlags (ManpageFlags, defaultManpageFlags, manpageOptions)
import Distribution.FieldGrammar.Newtypes (SpecVersion (..))

import Data.List
         ( deleteFirstsBy )
import System.FilePath
         ( (</>) )

globalCommand :: [Command action] -> CommandUI GlobalFlags
globalCommand :: [Command action] -> CommandUI GlobalFlags
globalCommand [Command action]
commands = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"",
    commandSynopsis :: String
commandSynopsis     =
         String
"Command line interface to the Haskell Cabal infrastructure.",
    commandUsage :: String -> String
commandUsage        = \String
pname ->
         String
"See http://www.haskell.org/cabal/ for more information.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" [GLOBAL FLAGS] [COMMAND [FLAGS]]\n",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
      let
        commands' :: [Command action]
commands' = [Command action]
commands [Command action] -> [Command action] -> [Command action]
forall a. [a] -> [a] -> [a]
++ [CommandUI () -> (() -> [String] -> action) -> Command action
forall flags action.
CommandUI flags -> (flags -> [String] -> action) -> Command action
commandAddAction CommandUI ()
helpCommandUI () -> [String] -> action
forall a. HasCallStack => a
undefined]
        cmdDescs :: [(String, String)]
cmdDescs = [Command action] -> [(String, String)]
forall action. [Command action] -> [(String, String)]
getNormalCommandDescriptions [Command action]
commands'
        -- if new commands are added, we want them to appear even if they
        -- are not included in the custom listing below. Thus, we calculate
        -- the `otherCmds` list and append it under the `other` category.
        -- Alternatively, a new testcase could be added that ensures that
        -- the set of commands listed here is equal to the set of commands
        -- that are actually available.
        otherCmds :: [String]
otherCmds = (String -> String -> Bool) -> [String] -> [String] -> [String]
forall a. (a -> a -> Bool) -> [a] -> [a] -> [a]
deleteFirstsBy String -> String -> Bool
forall a. Eq a => a -> a -> Bool
(==) (((String, String) -> String) -> [(String, String)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, String) -> String
forall a b. (a, b) -> a
fst [(String, String)]
cmdDescs)
          [ String
"help"
          , String
"update"
          , String
"install"
          , String
"fetch"
          , String
"list"
          , String
"info"
          , String
"user-config"
          , String
"get"
          , String
"unpack"
          , String
"init"
          , String
"configure"
          , String
"build"
          , String
"clean"
          , String
"run"
          , String
"repl"
          , String
"test"
          , String
"bench"
          , String
"check"
          , String
"sdist"
          , String
"upload"
          , String
"report"
          , String
"freeze"
          , String
"gen-bounds"
          , String
"outdated"
          , String
"haddock"
          , String
"hscolour"
          , String
"exec"
          , String
"new-build"
          , String
"new-configure"
          , String
"new-repl"
          , String
"new-freeze"
          , String
"new-run"
          , String
"new-test"
          , String
"new-bench"
          , String
"new-haddock"
          , String
"new-exec"
          , String
"new-update"
          , String
"new-install"
          , String
"new-clean"
          , String
"new-sdist"
          , String
"list-bin"
          -- v1 commands, stateful style
          , String
"v1-build"
          , String
"v1-configure"
          , String
"v1-repl"
          , String
"v1-freeze"
          , String
"v1-run"
          , String
"v1-test"
          , String
"v1-bench"
          , String
"v1-haddock"
          , String
"v1-exec"
          , String
"v1-update"
          , String
"v1-install"
          , String
"v1-clean"
          , String
"v1-sdist"
          , String
"v1-doctest"
          , String
"v1-copy"
          , String
"v1-register"
          , String
"v1-reconfigure"
          -- v2 commands, nix-style
          , String
"v2-build"
          , String
"v2-configure"
          , String
"v2-repl"
          , String
"v2-freeze"
          , String
"v2-run"
          , String
"v2-test"
          , String
"v2-bench"
          , String
"v2-haddock"
          , String
"v2-exec"
          , String
"v2-update"
          , String
"v2-install"
          , String
"v2-clean"
          , String
"v2-sdist"
          ]
        maxlen :: Int
maxlen    = [Int] -> Int
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ [String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
name | (String
name, String
_) <- [(String, String)]
cmdDescs]
        align :: String -> String
align String
str = String
str String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
maxlen Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
str) Char
' '
        startGroup :: String -> String
startGroup String
n = String
" ["String -> String -> String
forall a. [a] -> [a] -> [a]
++String
nString -> String -> String
forall a. [a] -> [a] -> [a]
++String
"]"
        par :: String
par          = String
""
        addCmd :: String -> String
addCmd String
n     = case String -> [(String, String)] -> Maybe String
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup String
n [(String, String)]
cmdDescs of
                         Maybe String
Nothing -> String
""
                         Just String
d -> String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
align String
n String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
d
      in
         String
"Commands:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
unlines (
        [ String -> String
startGroup String
"global"
        , String -> String
addCmd String
"update"
        , String -> String
addCmd String
"install"
        , String
par
        , String -> String
addCmd String
"help"
        , String -> String
addCmd String
"info"
        , String -> String
addCmd String
"list"
        , String -> String
addCmd String
"fetch"
        , String -> String
addCmd String
"user-config"
        , String
par
        , String -> String
startGroup String
"package"
        , String -> String
addCmd String
"get"
        , String -> String
addCmd String
"unpack"
        , String -> String
addCmd String
"init"
        , String
par
        , String -> String
addCmd String
"configure"
        , String -> String
addCmd String
"build"
        , String -> String
addCmd String
"clean"
        , String
par
        , String -> String
addCmd String
"run"
        , String -> String
addCmd String
"repl"
        , String -> String
addCmd String
"test"
        , String -> String
addCmd String
"bench"
        , String
par
        , String -> String
addCmd String
"check"
        , String -> String
addCmd String
"sdist"
        , String -> String
addCmd String
"upload"
        , String -> String
addCmd String
"report"
        , String
par
        , String -> String
addCmd String
"freeze"
        , String -> String
addCmd String
"gen-bounds"
        , String -> String
addCmd String
"outdated"
        , String -> String
addCmd String
"haddock"
        , String -> String
addCmd String
"hscolour"
        , String -> String
addCmd String
"exec"
        , String -> String
addCmd String
"list-bin"
        , String
par
        , String -> String
startGroup String
"new-style projects (forwards-compatible aliases)"
        , String -> String
addCmd String
"v2-build"
        , String -> String
addCmd String
"v2-configure"
        , String -> String
addCmd String
"v2-repl"
        , String -> String
addCmd String
"v2-run"
        , String -> String
addCmd String
"v2-test"
        , String -> String
addCmd String
"v2-bench"
        , String -> String
addCmd String
"v2-freeze"
        , String -> String
addCmd String
"v2-haddock"
        , String -> String
addCmd String
"v2-exec"
        , String -> String
addCmd String
"v2-update"
        , String -> String
addCmd String
"v2-install"
        , String -> String
addCmd String
"v2-clean"
        , String -> String
addCmd String
"v2-sdist"
        , String
par
        , String -> String
startGroup String
"legacy command aliases"
        , String -> String
addCmd String
"v1-build"
        , String -> String
addCmd String
"v1-configure"
        , String -> String
addCmd String
"v1-repl"
        , String -> String
addCmd String
"v1-run"
        , String -> String
addCmd String
"v1-test"
        , String -> String
addCmd String
"v1-bench"
        , String -> String
addCmd String
"v1-freeze"
        , String -> String
addCmd String
"v1-haddock"
        , String -> String
addCmd String
"v1-exec"
        , String -> String
addCmd String
"v1-update"
        , String -> String
addCmd String
"v1-install"
        , String -> String
addCmd String
"v1-clean"
        , String -> String
addCmd String
"v1-sdist"
        , String -> String
addCmd String
"v1-doctest"
        , String -> String
addCmd String
"v1-copy"
        , String -> String
addCmd String
"v1-register"
        , String -> String
addCmd String
"v1-reconfigure"
        ] [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ if [String] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
otherCmds then [] else String
par
                                           String -> [String] -> [String]
forall a. a -> [a] -> [a]
:String -> String
startGroup String
"other"
                                           String -> [String] -> [String]
forall a. a -> [a] -> [a]
:[String -> String
addCmd String
n | String
n <- [String]
otherCmds])
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"For more information about a command use:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"   " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" COMMAND --help\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"or " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" help COMMAND\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"To install Cabal packages from hackage use:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" install foo [--dry-run]\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Occasionally you need to update the list of available packages:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" update\n",
    commandNotes :: Maybe (String -> String)
commandNotes = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandDefaultFlags :: GlobalFlags
commandDefaultFlags = GlobalFlags
forall a. Monoid a => a
mempty,
    commandOptions :: ShowOrParseArgs -> [OptionField GlobalFlags]
commandOptions = ShowOrParseArgs -> [OptionField GlobalFlags]
args
  }
  where
    args :: ShowOrParseArgs -> [OptionField GlobalFlags]
    args :: ShowOrParseArgs -> [OptionField GlobalFlags]
args ShowOrParseArgs
ShowArgs  = [OptionField GlobalFlags]
argsShown
    args ShowOrParseArgs
ParseArgs = [OptionField GlobalFlags]
argsShown [OptionField GlobalFlags]
-> [OptionField GlobalFlags] -> [OptionField GlobalFlags]
forall a. [a] -> [a] -> [a]
++ [OptionField GlobalFlags]
argsNotShown

    -- arguments we want to show in the help
    argsShown :: [OptionField GlobalFlags]
    argsShown :: [OptionField GlobalFlags]
argsShown = [
       String
-> [String]
-> String
-> (GlobalFlags -> Flag Bool)
-> (Flag Bool -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [Char
'V'] [String
"version"]
         String
"Print version information"
         GlobalFlags -> Flag Bool
globalVersion (\Flag Bool
v GlobalFlags
flags -> GlobalFlags
flags { globalVersion :: Flag Bool
globalVersion = Flag Bool
v })
         MkOptDescr
  (GlobalFlags -> Flag Bool)
  (Flag Bool -> GlobalFlags -> GlobalFlags)
  GlobalFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag Bool)
-> (Flag Bool -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"numeric-version"]
         String
"Print just the version number"
         GlobalFlags -> Flag Bool
globalNumericVersion (\Flag Bool
v GlobalFlags
flags -> GlobalFlags
flags { globalNumericVersion :: Flag Bool
globalNumericVersion = Flag Bool
v })
         MkOptDescr
  (GlobalFlags -> Flag Bool)
  (Flag Bool -> GlobalFlags -> GlobalFlags)
  GlobalFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag String)
-> (Flag String -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"config-file"]
         String
"Set an alternate location for the config file"
         GlobalFlags -> Flag String
globalConfigFile (\Flag String
v GlobalFlags
flags -> GlobalFlags
flags { globalConfigFile :: Flag String
globalConfigFile = Flag String
v })
         (String
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"FILE")

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag Bool)
-> (Flag Bool -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"ignore-expiry"]
         String
"Ignore expiry dates on signed metadata (use only in exceptional circumstances)"
         GlobalFlags -> Flag Bool
globalIgnoreExpiry (\Flag Bool
v GlobalFlags
flags -> GlobalFlags
flags { globalIgnoreExpiry :: Flag Bool
globalIgnoreExpiry = Flag Bool
v })
         MkOptDescr
  (GlobalFlags -> Flag Bool)
  (Flag Bool -> GlobalFlags -> GlobalFlags)
  GlobalFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag String)
-> (Flag String -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"http-transport"]
         String
"Set a transport for http(s) requests. Accepts 'curl', 'wget', 'powershell', and 'plain-http'. (default: 'curl')"
         GlobalFlags -> Flag String
globalHttpTransport (\Flag String
v GlobalFlags
flags -> GlobalFlags
flags { globalHttpTransport :: Flag String
globalHttpTransport = Flag String
v })
         (String
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"HttpTransport")

      ,String
-> (GlobalFlags -> Flag Bool)
-> (Flag Bool -> GlobalFlags -> GlobalFlags)
-> [(GlobalFlags -> Flag Bool)
    -> (Flag Bool -> GlobalFlags -> GlobalFlags)
    -> OptDescr GlobalFlags]
-> OptionField GlobalFlags
forall get set a.
String -> get -> set -> [get -> set -> OptDescr a] -> OptionField a
multiOption String
"nix"
        GlobalFlags -> Flag Bool
globalNix (\Flag Bool
v GlobalFlags
flags -> GlobalFlags
flags { globalNix :: Flag Bool
globalNix = Flag Bool
v })
        [
          Flag Bool
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
True) [] [String
"enable-nix"]
          String
"Enable Nix integration: run commands through nix-shell if a 'shell.nix' file exists",
          Flag Bool
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False) [] [String
"disable-nix"]
          String
"Disable Nix integration"
        ]

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag String)
-> (Flag String -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"store-dir", String
"storedir"]
         String
"The location of the build store"
         GlobalFlags -> Flag String
globalStoreDir (\Flag String
v GlobalFlags
flags -> GlobalFlags
flags { globalStoreDir :: Flag String
globalStoreDir = Flag String
v })
         (String
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"DIR")

      , String
-> [String]
-> String
-> (GlobalFlags -> Flag ActiveRepos)
-> (Flag ActiveRepos -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag ActiveRepos)
     (Flag ActiveRepos -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"active-repositories"]
         String
"The active package repositories (set to ':none' to disable all repositories)"
         GlobalFlags -> Flag ActiveRepos
globalActiveRepos (\Flag ActiveRepos
v GlobalFlags
flags ->  GlobalFlags
flags { globalActiveRepos :: Flag ActiveRepos
globalActiveRepos = Flag ActiveRepos
v })
         (String
-> ReadE (Flag ActiveRepos)
-> (Flag ActiveRepos -> [String])
-> MkOptDescr
     (GlobalFlags -> Flag ActiveRepos)
     (Flag ActiveRepos -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"REPOS" ((String -> String)
-> ParsecParser (Flag ActiveRepos) -> ReadE (Flag ActiveRepos)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (\String
err -> String
"Error parsing active-repositories: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
err)
                                        (ActiveRepos -> Flag ActiveRepos
forall a. a -> Flag a
toFlag (ActiveRepos -> Flag ActiveRepos)
-> ParsecParser ActiveRepos -> ParsecParser (Flag ActiveRepos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser ActiveRepos
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec))
                         ((ActiveRepos -> String) -> [ActiveRepos] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ActiveRepos -> String
forall a. Pretty a => a -> String
prettyShow ([ActiveRepos] -> [String])
-> (Flag ActiveRepos -> [ActiveRepos])
-> Flag ActiveRepos
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag ActiveRepos -> [ActiveRepos]
forall a. Flag a -> [a]
flagToList))
      ]

    -- arguments we don't want shown in the help
    -- the remote repo flags are not useful compared to the more general "active-repositories" flag.
    -- the global logs directory was only used in v1, while in v2 we have specific project config logs dirs
    -- default-user-config is support for a relatively obscure workflow for v1-freeze.
    argsNotShown :: [OptionField GlobalFlags]
    argsNotShown :: [OptionField GlobalFlags]
argsNotShown = [
       String
-> [String]
-> String
-> (GlobalFlags -> NubList RemoteRepo)
-> (NubList RemoteRepo -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> NubList RemoteRepo)
     (NubList RemoteRepo -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"remote-repo"]
         String
"The name and url for a remote repository"
         GlobalFlags -> NubList RemoteRepo
globalRemoteRepos (\NubList RemoteRepo
v GlobalFlags
flags -> GlobalFlags
flags { globalRemoteRepos :: NubList RemoteRepo
globalRemoteRepos = NubList RemoteRepo
v })
         (String
-> (String -> NubList RemoteRepo)
-> (NubList RemoteRepo -> [String])
-> MkOptDescr
     (GlobalFlags -> NubList RemoteRepo)
     (NubList RemoteRepo -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"NAME:URL" ([RemoteRepo] -> NubList RemoteRepo
forall a. Ord a => [a] -> NubList a
toNubList ([RemoteRepo] -> NubList RemoteRepo)
-> (String -> [RemoteRepo]) -> String -> NubList RemoteRepo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe RemoteRepo -> [RemoteRepo]
forall a. Maybe a -> [a]
maybeToList (Maybe RemoteRepo -> [RemoteRepo])
-> (String -> Maybe RemoteRepo) -> String -> [RemoteRepo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe RemoteRepo
readRemoteRepo) ((RemoteRepo -> String) -> [RemoteRepo] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map RemoteRepo -> String
showRemoteRepo ([RemoteRepo] -> [String])
-> (NubList RemoteRepo -> [RemoteRepo])
-> NubList RemoteRepo
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NubList RemoteRepo -> [RemoteRepo]
forall a. NubList a -> [a]
fromNubList))

      ,String
-> [String]
-> String
-> (GlobalFlags -> NubList LocalRepo)
-> (NubList LocalRepo -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> NubList LocalRepo)
     (NubList LocalRepo -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"local-no-index-repo"]
         String
"The name and a path for a local no-index repository"
         GlobalFlags -> NubList LocalRepo
globalLocalNoIndexRepos (\NubList LocalRepo
v GlobalFlags
flags -> GlobalFlags
flags { globalLocalNoIndexRepos :: NubList LocalRepo
globalLocalNoIndexRepos = NubList LocalRepo
v })
         (String
-> (String -> NubList LocalRepo)
-> (NubList LocalRepo -> [String])
-> MkOptDescr
     (GlobalFlags -> NubList LocalRepo)
     (NubList LocalRepo -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"NAME:PATH" ([LocalRepo] -> NubList LocalRepo
forall a. Ord a => [a] -> NubList a
toNubList ([LocalRepo] -> NubList LocalRepo)
-> (String -> [LocalRepo]) -> String -> NubList LocalRepo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe LocalRepo -> [LocalRepo]
forall a. Maybe a -> [a]
maybeToList (Maybe LocalRepo -> [LocalRepo])
-> (String -> Maybe LocalRepo) -> String -> [LocalRepo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe LocalRepo
readLocalRepo) ((LocalRepo -> String) -> [LocalRepo] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map LocalRepo -> String
showLocalRepo ([LocalRepo] -> [String])
-> (NubList LocalRepo -> [LocalRepo])
-> NubList LocalRepo
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NubList LocalRepo -> [LocalRepo]
forall a. NubList a -> [a]
fromNubList))

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag String)
-> (Flag String -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"remote-repo-cache"]
         String
"The location where downloads from all remote repos are cached"
         GlobalFlags -> Flag String
globalCacheDir (\Flag String
v GlobalFlags
flags -> GlobalFlags
flags { globalCacheDir :: Flag String
globalCacheDir = Flag String
v })
         (String
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"DIR")

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag String)
-> (Flag String -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"logs-dir", String
"logsdir"]
         String
"The location to put log files"
         GlobalFlags -> Flag String
globalLogsDir (\Flag String
v GlobalFlags
flags -> GlobalFlags
flags { globalLogsDir :: Flag String
globalLogsDir = Flag String
v })
         (String
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"DIR")

      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag String)
-> (Flag String -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"default-user-config"]
         String
"Set a location for a cabal.config file for projects without their own cabal.config freeze file."
         GlobalFlags -> Flag String
globalConstraintsFile (\Flag String
v GlobalFlags
flags -> GlobalFlags
flags {globalConstraintsFile :: Flag String
globalConstraintsFile = Flag String
v})
         (String
-> MkOptDescr
     (GlobalFlags -> Flag String)
     (Flag String -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"FILE")

      ]

-- ------------------------------------------------------------
-- * Config flags
-- ------------------------------------------------------------

configureCommand :: CommandUI ConfigFlags
configureCommand :: CommandUI ConfigFlags
configureCommand = CommandUI ConfigFlags
c
  { commandName :: String
commandName         = String
"configure"
  , commandDefaultFlags :: ConfigFlags
commandDefaultFlags = ConfigFlags
forall a. Monoid a => a
mempty
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Configure how the package is built by setting "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"package (and other) flags.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"The configuration affects several other commands, "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"including v1-build, v1-test, v1-bench, v1-run, v1-repl.\n"
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
    String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-configure [FLAGS]\n"
  , commandNotes :: Maybe (String -> String)
commandNotes = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
    (ProgramDb -> String
Cabal.programFlagsDescription ProgramDb
defaultProgramDb String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n")
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Examples:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-configure\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Configure with defaults;\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-configure --enable-tests -fcustomflag\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Configure building package including tests,\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    with some package-specific flag.\n"
  }
 where
  c :: CommandUI ConfigFlags
c = ProgramDb -> CommandUI ConfigFlags
Cabal.configureCommand ProgramDb
defaultProgramDb

configureOptions ::  ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions = CommandUI ConfigFlags
-> ShowOrParseArgs -> [OptionField ConfigFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI ConfigFlags
configureCommand

-- | Given some 'ConfigFlags' for the version of Cabal that
-- cabal-install was built with, and a target older 'Version' of
-- Cabal that we want to pass these flags to, convert the
-- flags into a form that will be accepted by the older
-- Setup script.  Generally speaking, this just means filtering
-- out flags that the old Cabal library doesn't understand, but
-- in some cases it may also mean "emulating" a feature using
-- some more legacy flags.
filterConfigureFlags :: ConfigFlags -> Version -> ConfigFlags
filterConfigureFlags :: ConfigFlags -> Version -> ConfigFlags
filterConfigureFlags ConfigFlags
flags Version
cabalLibVersion
  -- NB: we expect the latest version to be the most common case,
  -- so test it first.
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int] -> Version
mkVersion [Int
3,Int
7,Int
0]  = ConfigFlags
flags_latest
  -- The naming convention is that flags_version gives flags with
  -- all flags *introduced* in version eliminated.
  -- It is NOT the latest version of Cabal library that
  -- these flags work for; version of introduction is a more
  -- natural metric.
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
3,Int
10] = ConfigFlags
flags_1_3_10
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
10,Int
0] = ConfigFlags
flags_1_10_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
12,Int
0] = ConfigFlags
flags_1_12_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
14,Int
0] = ConfigFlags
flags_1_14_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
18,Int
0] = ConfigFlags
flags_1_18_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
19,Int
1] = ConfigFlags
flags_1_19_1
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
19,Int
2] = ConfigFlags
flags_1_19_2
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
21,Int
1] = ConfigFlags
flags_1_21_1
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
22,Int
0] = ConfigFlags
flags_1_22_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
22,Int
1] = ConfigFlags
flags_1_22_1
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
23,Int
0] = ConfigFlags
flags_1_23_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
1,Int
25,Int
0] = ConfigFlags
flags_1_25_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
2,Int
1,Int
0]  = ConfigFlags
flags_2_1_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
2,Int
5,Int
0]  = ConfigFlags
flags_2_5_0
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
3,Int
7,Int
0]  = ConfigFlags
flags_3_7_0
  | Bool
otherwise = String -> ConfigFlags
forall a. HasCallStack => String -> a
error String
"the impossible just happened" -- see first guard
  where
    flags_latest :: ConfigFlags
flags_latest = ConfigFlags
flags        {
      -- Cabal >= 1.19.1 uses '--dependency' and does not need '--constraint'.
      -- Note: this is not in the wrong place. configConstraints gets
      -- repopulated in flags_1_19_1 but it needs to be set to empty for
      -- newer versions first.
      configConstraints :: [PackageVersionConstraint]
configConstraints = []
      }

    flags_3_7_0 :: ConfigFlags
flags_3_7_0 = ConfigFlags
flags_latest {
        -- Cabal < 3.7 does not know about --extra-lib-dirs-static
        configExtraLibDirsStatic :: [String]
configExtraLibDirsStatic = [],

        -- Cabal < 3.7 does not understand '--enable-build-info' or '--disable-build-info'
        configDumpBuildInfo :: Flag DumpBuildInfo
configDumpBuildInfo = Flag DumpBuildInfo
forall a. Flag a
NoFlag
      }

    flags_2_5_0 :: ConfigFlags
flags_2_5_0 = ConfigFlags
flags_3_7_0 {
      -- Cabal < 2.5 does not understand --dependency=pkg:component=cid
      -- (public sublibraries), so we convert it to the legacy
      -- --dependency=pkg_or_internal_compoent=cid
        configDependencies :: [GivenComponent]
configDependencies =
          let convertToLegacyInternalDep :: GivenComponent -> Maybe GivenComponent
convertToLegacyInternalDep (GivenComponent PackageName
_ (LSubLibName UnqualComponentName
cn) ComponentId
cid) =
                GivenComponent -> Maybe GivenComponent
forall a. a -> Maybe a
Just (GivenComponent -> Maybe GivenComponent)
-> GivenComponent -> Maybe GivenComponent
forall a b. (a -> b) -> a -> b
$ PackageName -> LibraryName -> ComponentId -> GivenComponent
GivenComponent
                       (UnqualComponentName -> PackageName
unqualComponentNameToPackageName UnqualComponentName
cn)
                       LibraryName
LMainLibName
                       ComponentId
cid
              convertToLegacyInternalDep (GivenComponent PackageName
pn LibraryName
LMainLibName ComponentId
cid) =
                GivenComponent -> Maybe GivenComponent
forall a. a -> Maybe a
Just (GivenComponent -> Maybe GivenComponent)
-> GivenComponent -> Maybe GivenComponent
forall a b. (a -> b) -> a -> b
$ PackageName -> LibraryName -> ComponentId -> GivenComponent
GivenComponent PackageName
pn LibraryName
LMainLibName ComponentId
cid
          in [Maybe GivenComponent] -> [GivenComponent]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe GivenComponent] -> [GivenComponent])
-> [Maybe GivenComponent] -> [GivenComponent]
forall a b. (a -> b) -> a -> b
$ GivenComponent -> Maybe GivenComponent
convertToLegacyInternalDep (GivenComponent -> Maybe GivenComponent)
-> [GivenComponent] -> [Maybe GivenComponent]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConfigFlags -> [GivenComponent]
configDependencies ConfigFlags
flags
        -- Cabal < 2.5 doesn't know about '--allow-depending-on-private-libs'.
      , configAllowDependingOnPrivateLibs :: Flag Bool
configAllowDependingOnPrivateLibs = Flag Bool
forall a. Flag a
NoFlag
        -- Cabal < 2.5 doesn't know about '--enable/disable-executable-static'.
      , configFullyStaticExe :: Flag Bool
configFullyStaticExe = Flag Bool
forall a. Flag a
NoFlag
      }

    flags_2_1_0 :: ConfigFlags
flags_2_1_0 = ConfigFlags
flags_2_5_0 {
      -- Cabal < 2.1 doesn't know about -v +timestamp modifier
        configVerbosity :: Flag Verbosity
configVerbosity   = (Verbosity -> Verbosity) -> Flag Verbosity -> Flag Verbosity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Verbosity -> Verbosity
verboseNoTimestamp (ConfigFlags -> Flag Verbosity
configVerbosity ConfigFlags
flags_latest)
      -- Cabal < 2.1 doesn't know about --<enable|disable>-static
      , configStaticLib :: Flag Bool
configStaticLib   = Flag Bool
forall a. Flag a
NoFlag
      , configSplitSections :: Flag Bool
configSplitSections = Flag Bool
forall a. Flag a
NoFlag
      }

    flags_1_25_0 :: ConfigFlags
flags_1_25_0 = ConfigFlags
flags_2_1_0 {
      -- Cabal < 1.25.0 doesn't know about --dynlibdir.
      configInstallDirs :: InstallDirs (Flag PathTemplate)
configInstallDirs = InstallDirs (Flag PathTemplate)
configInstallDirs_1_25_0,
      -- Cabal < 1.25 doesn't have extended verbosity syntax
      configVerbosity :: Flag Verbosity
configVerbosity   = (Verbosity -> Verbosity) -> Flag Verbosity -> Flag Verbosity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Verbosity -> Verbosity
verboseNoFlags (ConfigFlags -> Flag Verbosity
configVerbosity ConfigFlags
flags_2_1_0),
      -- Cabal < 1.25 doesn't support --deterministic
      configDeterministic :: Flag Bool
configDeterministic = Flag Bool
forall a. Monoid a => a
mempty
      }
    configInstallDirs_1_25_0 :: InstallDirs (Flag PathTemplate)
configInstallDirs_1_25_0 = let dirs :: InstallDirs (Flag PathTemplate)
dirs = ConfigFlags -> InstallDirs (Flag PathTemplate)
configInstallDirs ConfigFlags
flags in
        InstallDirs (Flag PathTemplate)
dirs { dynlibdir :: Flag PathTemplate
dynlibdir = Flag PathTemplate
forall a. Flag a
NoFlag
             , libexecsubdir :: Flag PathTemplate
libexecsubdir = Flag PathTemplate
forall a. Flag a
NoFlag
             , libexecdir :: Flag PathTemplate
libexecdir = Maybe PathTemplate -> Flag PathTemplate
forall a. Maybe a -> Flag a
maybeToFlag (Maybe PathTemplate -> Flag PathTemplate)
-> Maybe PathTemplate -> Flag PathTemplate
forall a b. (a -> b) -> a -> b
$
                 PathTemplate -> PathTemplate -> PathTemplate
combinePathTemplate (PathTemplate -> PathTemplate -> PathTemplate)
-> Maybe PathTemplate -> Maybe (PathTemplate -> PathTemplate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Flag PathTemplate -> Maybe PathTemplate
forall a. Flag a -> Maybe a
flagToMaybe (InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
libexecdir InstallDirs (Flag PathTemplate)
dirs)
                                     Maybe (PathTemplate -> PathTemplate)
-> Maybe PathTemplate -> Maybe PathTemplate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Flag PathTemplate -> Maybe PathTemplate
forall a. Flag a -> Maybe a
flagToMaybe (InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
libexecsubdir InstallDirs (Flag PathTemplate)
dirs)
             }
    -- Cabal < 1.23 doesn't know about '--profiling-detail'.
    -- Cabal < 1.23 has a hacked up version of 'enable-profiling'
    -- which we shouldn't use.
    (Bool
tryLibProfiling, Bool
tryExeProfiling) = ConfigFlags -> (Bool, Bool)
computeEffectiveProfiling ConfigFlags
flags
    flags_1_23_0 :: ConfigFlags
flags_1_23_0 = ConfigFlags
flags_1_25_0 { configProfDetail :: Flag ProfDetailLevel
configProfDetail    = Flag ProfDetailLevel
forall a. Flag a
NoFlag
                                , configProfLibDetail :: Flag ProfDetailLevel
configProfLibDetail = Flag ProfDetailLevel
forall a. Flag a
NoFlag
                                , configIPID :: Flag String
configIPID          = Flag String
forall a. Flag a
NoFlag
                                , configProf :: Flag Bool
configProf          = Flag Bool
forall a. Flag a
NoFlag
                                , configProfExe :: Flag Bool
configProfExe       = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
tryExeProfiling
                                , configProfLib :: Flag Bool
configProfLib       = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
tryLibProfiling
                                }

    -- Cabal == 1.22.0.* had a discontinuity (see #5946 or e9a8d48a3adce34d)
    -- due to temporary amnesia of the --*-executable-profiling flags
    flags_1_22_1 :: ConfigFlags
flags_1_22_1 = ConfigFlags
flags_1_23_0 { configDebugInfo :: Flag DebugInfoLevel
configDebugInfo = Flag DebugInfoLevel
forall a. Flag a
NoFlag
                                , configProfExe :: Flag Bool
configProfExe   = Flag Bool
forall a. Flag a
NoFlag
                                }

    -- Cabal < 1.22 doesn't know about '--disable-debug-info'.
    flags_1_22_0 :: ConfigFlags
flags_1_22_0 = ConfigFlags
flags_1_23_0 { configDebugInfo :: Flag DebugInfoLevel
configDebugInfo = Flag DebugInfoLevel
forall a. Flag a
NoFlag }

    -- Cabal < 1.21.1 doesn't know about 'disable-relocatable'
    -- Cabal < 1.21.1 doesn't know about 'enable-profiling'
    -- (but we already dealt with it in flags_1_23_0)
    flags_1_21_1 :: ConfigFlags
flags_1_21_1 =
      ConfigFlags
flags_1_22_0 { configRelocatable :: Flag Bool
configRelocatable = Flag Bool
forall a. Flag a
NoFlag
                   , configCoverage :: Flag Bool
configCoverage = Flag Bool
forall a. Flag a
NoFlag
                   , configLibCoverage :: Flag Bool
configLibCoverage = ConfigFlags -> Flag Bool
configCoverage ConfigFlags
flags
                   }
    -- Cabal < 1.19.2 doesn't know about '--exact-configuration' and
    -- '--enable-library-stripping'.
    flags_1_19_2 :: ConfigFlags
flags_1_19_2 = ConfigFlags
flags_1_21_1 { configExactConfiguration :: Flag Bool
configExactConfiguration = Flag Bool
forall a. Flag a
NoFlag
                                , configStripLibs :: Flag Bool
configStripLibs = Flag Bool
forall a. Flag a
NoFlag }
    -- Cabal < 1.19.1 uses '--constraint' instead of '--dependency'.
    flags_1_19_1 :: ConfigFlags
flags_1_19_1 = ConfigFlags
flags_1_19_2 { configDependencies :: [GivenComponent]
configDependencies = []
                                , configConstraints :: [PackageVersionConstraint]
configConstraints  = ConfigFlags -> [PackageVersionConstraint]
configConstraints ConfigFlags
flags }
    -- Cabal < 1.18.0 doesn't know about --extra-prog-path and --sysconfdir.
    flags_1_18_0 :: ConfigFlags
flags_1_18_0 = ConfigFlags
flags_1_19_1 { configProgramPathExtra :: NubList String
configProgramPathExtra = [String] -> NubList String
forall a. Ord a => [a] -> NubList a
toNubList []
                                , configInstallDirs :: InstallDirs (Flag PathTemplate)
configInstallDirs = InstallDirs (Flag PathTemplate)
configInstallDirs_1_18_0}
    configInstallDirs_1_18_0 :: InstallDirs (Flag PathTemplate)
configInstallDirs_1_18_0 = (ConfigFlags -> InstallDirs (Flag PathTemplate)
configInstallDirs ConfigFlags
flags_1_19_1) { sysconfdir :: Flag PathTemplate
sysconfdir = Flag PathTemplate
forall a. Flag a
NoFlag }
    -- Cabal < 1.14.0 doesn't know about '--disable-benchmarks'.
    flags_1_14_0 :: ConfigFlags
flags_1_14_0 = ConfigFlags
flags_1_18_0 { configBenchmarks :: Flag Bool
configBenchmarks  = Flag Bool
forall a. Flag a
NoFlag }
    -- Cabal < 1.12.0 doesn't know about '--enable/disable-executable-dynamic'
    -- and '--enable/disable-library-coverage'.
    flags_1_12_0 :: ConfigFlags
flags_1_12_0 = ConfigFlags
flags_1_14_0 { configLibCoverage :: Flag Bool
configLibCoverage = Flag Bool
forall a. Flag a
NoFlag
                                , configDynExe :: Flag Bool
configDynExe      = Flag Bool
forall a. Flag a
NoFlag }
    -- Cabal < 1.10.0 doesn't know about '--disable-tests'.
    flags_1_10_0 :: ConfigFlags
flags_1_10_0 = ConfigFlags
flags_1_12_0 { configTests :: Flag Bool
configTests       = Flag Bool
forall a. Flag a
NoFlag }
    -- Cabal < 1.3.10 does not grok the '--constraints' flag.
    flags_1_3_10 :: ConfigFlags
flags_1_3_10 = ConfigFlags
flags_1_10_0 { configConstraints :: [PackageVersionConstraint]
configConstraints = [] }

-- | Get the package database settings from 'ConfigFlags', accounting for
-- @--package-db@ and @--user@ flags.
configPackageDB' :: ConfigFlags -> PackageDBStack
configPackageDB' :: ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
cfg =
    Bool -> [Maybe PackageDB] -> PackageDBStack
interpretPackageDbFlags Bool
userInstall (ConfigFlags -> [Maybe PackageDB]
configPackageDBs ConfigFlags
cfg)
  where
    userInstall :: Bool
userInstall = Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
Cabal.fromFlagOrDefault Bool
True (ConfigFlags -> Flag Bool
configUserInstall ConfigFlags
cfg)

-- | Configure the compiler, but reduce verbosity during this step.
configCompilerAux' :: ConfigFlags -> IO (Compiler, Platform, ProgramDb)
configCompilerAux' :: ConfigFlags -> IO (Compiler, Platform, ProgramDb)
configCompilerAux' ConfigFlags
configFlags =
  ConfigFlags -> IO (Compiler, Platform, ProgramDb)
configCompilerAuxEx ConfigFlags
configFlags
    --FIXME: make configCompilerAux use a sensible verbosity
    { configVerbosity :: Flag Verbosity
configVerbosity = (Verbosity -> Verbosity) -> Flag Verbosity -> Flag Verbosity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Verbosity -> Verbosity
lessVerbose (ConfigFlags -> Flag Verbosity
configVerbosity ConfigFlags
configFlags) }

-- ------------------------------------------------------------
-- * Config extra flags
-- ------------------------------------------------------------

-- | cabal configure takes some extra flags beyond runghc Setup configure
--
data ConfigExFlags = ConfigExFlags {
    ConfigExFlags -> Flag Version
configCabalVersion  :: Flag Version,
    ConfigExFlags -> Flag Bool
configAppend        :: Flag Bool,
    ConfigExFlags -> Flag Bool
configBackup        :: Flag Bool,
    ConfigExFlags -> [(UserConstraint, ConstraintSource)]
configExConstraints :: [(UserConstraint, ConstraintSource)],
    ConfigExFlags -> [PackageVersionConstraint]
configPreferences   :: [PackageVersionConstraint],
    ConfigExFlags -> Flag PreSolver
configSolver        :: Flag PreSolver,
    ConfigExFlags -> Maybe AllowNewer
configAllowNewer    :: Maybe AllowNewer,
    ConfigExFlags -> Maybe AllowOlder
configAllowOlder    :: Maybe AllowOlder,
    ConfigExFlags -> Flag WriteGhcEnvironmentFilesPolicy
configWriteGhcEnvironmentFilesPolicy
      :: Flag WriteGhcEnvironmentFilesPolicy
  }
  deriving (ConfigExFlags -> ConfigExFlags -> Bool
(ConfigExFlags -> ConfigExFlags -> Bool)
-> (ConfigExFlags -> ConfigExFlags -> Bool) -> Eq ConfigExFlags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigExFlags -> ConfigExFlags -> Bool
$c/= :: ConfigExFlags -> ConfigExFlags -> Bool
== :: ConfigExFlags -> ConfigExFlags -> Bool
$c== :: ConfigExFlags -> ConfigExFlags -> Bool
Eq, Int -> ConfigExFlags -> String -> String
[ConfigExFlags] -> String -> String
ConfigExFlags -> String
(Int -> ConfigExFlags -> String -> String)
-> (ConfigExFlags -> String)
-> ([ConfigExFlags] -> String -> String)
-> Show ConfigExFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [ConfigExFlags] -> String -> String
$cshowList :: [ConfigExFlags] -> String -> String
show :: ConfigExFlags -> String
$cshow :: ConfigExFlags -> String
showsPrec :: Int -> ConfigExFlags -> String -> String
$cshowsPrec :: Int -> ConfigExFlags -> String -> String
Show, (forall x. ConfigExFlags -> Rep ConfigExFlags x)
-> (forall x. Rep ConfigExFlags x -> ConfigExFlags)
-> Generic ConfigExFlags
forall x. Rep ConfigExFlags x -> ConfigExFlags
forall x. ConfigExFlags -> Rep ConfigExFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigExFlags x -> ConfigExFlags
$cfrom :: forall x. ConfigExFlags -> Rep ConfigExFlags x
Generic)

defaultConfigExFlags :: ConfigExFlags
defaultConfigExFlags :: ConfigExFlags
defaultConfigExFlags = ConfigExFlags
forall a. Monoid a => a
mempty { configSolver :: Flag PreSolver
configSolver     = PreSolver -> Flag PreSolver
forall a. a -> Flag a
Flag PreSolver
defaultSolver }

configureExCommand :: CommandUI (ConfigFlags, ConfigExFlags)
configureExCommand :: CommandUI (ConfigFlags, ConfigExFlags)
configureExCommand = CommandUI ConfigFlags
configureCommand {
    commandDefaultFlags :: (ConfigFlags, ConfigExFlags)
commandDefaultFlags = (ConfigFlags
forall a. Monoid a => a
mempty, ConfigExFlags
defaultConfigExFlags),
    commandOptions :: ShowOrParseArgs -> [OptionField (ConfigFlags, ConfigExFlags)]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
         ((ConfigFlags, ConfigExFlags) -> ConfigFlags)
-> (ConfigFlags
    -> (ConfigFlags, ConfigExFlags) -> (ConfigFlags, ConfigExFlags))
-> [OptionField ConfigFlags]
-> [OptionField (ConfigFlags, ConfigExFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags) -> ConfigFlags
forall a b. (a, b) -> a
fst ConfigFlags
-> (ConfigFlags, ConfigExFlags) -> (ConfigFlags, ConfigExFlags)
forall a a b. a -> (a, b) -> (a, b)
setFst
         ((OptionField ConfigFlags -> Bool)
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String
"constraint", String
"dependency", String
"exact-configuration"])
                  (String -> Bool)
-> (OptionField ConfigFlags -> String)
-> OptionField ConfigFlags
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OptionField ConfigFlags -> String
forall a. OptionField a -> String
optionName) ([OptionField ConfigFlags] -> [OptionField ConfigFlags])
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a b. (a -> b) -> a -> b
$ ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions  ShowOrParseArgs
showOrParseArgs)
      [OptionField (ConfigFlags, ConfigExFlags)]
-> [OptionField (ConfigFlags, ConfigExFlags)]
-> [OptionField (ConfigFlags, ConfigExFlags)]
forall a. [a] -> [a] -> [a]
++ ((ConfigFlags, ConfigExFlags) -> ConfigExFlags)
-> (ConfigExFlags
    -> (ConfigFlags, ConfigExFlags) -> (ConfigFlags, ConfigExFlags))
-> [OptionField ConfigExFlags]
-> [OptionField (ConfigFlags, ConfigExFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags) -> ConfigExFlags
forall a b. (a, b) -> b
snd ConfigExFlags
-> (ConfigFlags, ConfigExFlags) -> (ConfigFlags, ConfigExFlags)
forall b a b. b -> (a, b) -> (a, b)
setSnd
         (ShowOrParseArgs -> ConstraintSource -> [OptionField ConfigExFlags]
configureExOptions ShowOrParseArgs
showOrParseArgs ConstraintSource
ConstraintSourceCommandlineFlag)
  }
  where
    setFst :: a -> (a, b) -> (a, b)
setFst a
a (a
_,b
b) = (a
a,b
b)
    setSnd :: b -> (a, b) -> (a, b)
setSnd b
b (a
a,b
_) = (a
a,b
b)

configureExOptions :: ShowOrParseArgs
                   -> ConstraintSource
                   -> [OptionField ConfigExFlags]
configureExOptions :: ShowOrParseArgs -> ConstraintSource -> [OptionField ConfigExFlags]
configureExOptions ShowOrParseArgs
_showOrParseArgs ConstraintSource
src =
  [ String
-> [String]
-> String
-> (ConfigExFlags -> Flag Version)
-> (Flag Version -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> Flag Version)
     (Flag Version -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"cabal-lib-version"]
      (String
"Select which version of the Cabal lib to use to build packages "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"(useful for testing).")
      ConfigExFlags -> Flag Version
configCabalVersion (\Flag Version
v ConfigExFlags
flags -> ConfigExFlags
flags { configCabalVersion :: Flag Version
configCabalVersion = Flag Version
v })
      (String
-> ReadE (Flag Version)
-> (Flag Version -> [String])
-> MkOptDescr
     (ConfigExFlags -> Flag Version)
     (Flag Version -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"VERSION" ((String -> String)
-> ParsecParser (Flag Version) -> ReadE (Flag Version)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String
"Cannot parse cabal lib version: "String -> String -> String
forall a. [a] -> [a] -> [a]
++)
                                    ((Version -> Flag Version)
-> ParsecParser Version -> ParsecParser (Flag Version)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Version -> Flag Version
forall a. a -> Flag a
toFlag ParsecParser Version
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec))
                        ((Version -> String) -> [Version] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Version -> String
forall a. Pretty a => a -> String
prettyShow([Version] -> [String])
-> (Flag Version -> [Version]) -> Flag Version -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag Version -> [Version]
forall a. Flag a -> [a]
flagToList))
  , String
-> [String]
-> String
-> (ConfigExFlags -> Flag Bool)
-> (Flag Bool -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> Flag Bool)
     (Flag Bool -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"append"]
      String
"appending the new config to the old config file"
      ConfigExFlags -> Flag Bool
configAppend (\Flag Bool
v ConfigExFlags
flags -> ConfigExFlags
flags { configAppend :: Flag Bool
configAppend = Flag Bool
v })
      (String
-> String
-> MkOptDescr
     (ConfigExFlags -> Flag Bool)
     (Flag Bool -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])
  , String
-> [String]
-> String
-> (ConfigExFlags -> Flag Bool)
-> (Flag Bool -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> Flag Bool)
     (Flag Bool -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"backup"]
      String
"the backup of the config file before any alterations"
      ConfigExFlags -> Flag Bool
configBackup (\Flag Bool
v ConfigExFlags
flags -> ConfigExFlags
flags { configBackup :: Flag Bool
configBackup = Flag Bool
v })
      (String
-> String
-> MkOptDescr
     (ConfigExFlags -> Flag Bool)
     (Flag Bool -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])
  , String
-> [String]
-> String
-> (ConfigExFlags -> [(UserConstraint, ConstraintSource)])
-> ([(UserConstraint, ConstraintSource)]
    -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> [(UserConstraint, ConstraintSource)])
     ([(UserConstraint, ConstraintSource)]
      -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"c" [String
"constraint"]
      String
"Specify constraints on a package (version, installed/source, flags)"
      ConfigExFlags -> [(UserConstraint, ConstraintSource)]
configExConstraints (\[(UserConstraint, ConstraintSource)]
v ConfigExFlags
flags -> ConfigExFlags
flags { configExConstraints :: [(UserConstraint, ConstraintSource)]
configExConstraints = [(UserConstraint, ConstraintSource)]
v })
      (String
-> ReadE [(UserConstraint, ConstraintSource)]
-> ([(UserConstraint, ConstraintSource)] -> [String])
-> MkOptDescr
     (ConfigExFlags -> [(UserConstraint, ConstraintSource)])
     ([(UserConstraint, ConstraintSource)]
      -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"CONSTRAINT"
              ((\UserConstraint
x -> [(UserConstraint
x, ConstraintSource
src)]) (UserConstraint -> [(UserConstraint, ConstraintSource)])
-> ReadE UserConstraint
-> ReadE [(UserConstraint, ConstraintSource)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` (String -> Either String UserConstraint) -> ReadE UserConstraint
forall a. (String -> Either String a) -> ReadE a
ReadE String -> Either String UserConstraint
readUserConstraint)
              (((UserConstraint, ConstraintSource) -> String)
-> [(UserConstraint, ConstraintSource)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (((UserConstraint, ConstraintSource) -> String)
 -> [(UserConstraint, ConstraintSource)] -> [String])
-> ((UserConstraint, ConstraintSource) -> String)
-> [(UserConstraint, ConstraintSource)]
-> [String]
forall a b. (a -> b) -> a -> b
$ UserConstraint -> String
forall a. Pretty a => a -> String
prettyShow (UserConstraint -> String)
-> ((UserConstraint, ConstraintSource) -> UserConstraint)
-> (UserConstraint, ConstraintSource)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (UserConstraint, ConstraintSource) -> UserConstraint
forall a b. (a, b) -> a
fst))

  , String
-> [String]
-> String
-> (ConfigExFlags -> [PackageVersionConstraint])
-> ([PackageVersionConstraint] -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> [PackageVersionConstraint])
     ([PackageVersionConstraint] -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"preference"]
      String
"Specify preferences (soft constraints) on the version of a package"
      ConfigExFlags -> [PackageVersionConstraint]
configPreferences (\[PackageVersionConstraint]
v ConfigExFlags
flags -> ConfigExFlags
flags { configPreferences :: [PackageVersionConstraint]
configPreferences = [PackageVersionConstraint]
v })
      (String
-> ReadE [PackageVersionConstraint]
-> ([PackageVersionConstraint] -> [String])
-> MkOptDescr
     (ConfigExFlags -> [PackageVersionConstraint])
     ([PackageVersionConstraint] -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"CONSTRAINT"
              ((String -> String)
-> ParsecParser [PackageVersionConstraint]
-> ReadE [PackageVersionConstraint]
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String -> String -> String
forall a b. a -> b -> a
const String
"dependency expected")
                          ((PackageVersionConstraint -> [PackageVersionConstraint])
-> ParsecParser PackageVersionConstraint
-> ParsecParser [PackageVersionConstraint]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\PackageVersionConstraint
x -> [PackageVersionConstraint
x]) ParsecParser PackageVersionConstraint
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec))
              ((PackageVersionConstraint -> String)
-> [PackageVersionConstraint] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map PackageVersionConstraint -> String
forall a. Pretty a => a -> String
prettyShow))

  , (ConfigExFlags -> Flag PreSolver)
-> (Flag PreSolver -> ConfigExFlags -> ConfigExFlags)
-> OptionField ConfigExFlags
forall flags.
(flags -> Flag PreSolver)
-> (Flag PreSolver -> flags -> flags) -> OptionField flags
optionSolver ConfigExFlags -> Flag PreSolver
configSolver (\Flag PreSolver
v ConfigExFlags
flags -> ConfigExFlags
flags { configSolver :: Flag PreSolver
configSolver = Flag PreSolver
v })

  , String
-> [String]
-> String
-> (ConfigExFlags -> Maybe RelaxDeps)
-> (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> Maybe RelaxDeps)
     (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"allow-older"]
    (String
"Ignore lower bounds in all dependencies or DEPS")
    ((AllowOlder -> RelaxDeps) -> Maybe AllowOlder -> Maybe RelaxDeps
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AllowOlder -> RelaxDeps
unAllowOlder (Maybe AllowOlder -> Maybe RelaxDeps)
-> (ConfigExFlags -> Maybe AllowOlder)
-> ConfigExFlags
-> Maybe RelaxDeps
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfigExFlags -> Maybe AllowOlder
configAllowOlder)
    (\Maybe RelaxDeps
v ConfigExFlags
flags -> ConfigExFlags
flags { configAllowOlder :: Maybe AllowOlder
configAllowOlder = (RelaxDeps -> AllowOlder) -> Maybe RelaxDeps -> Maybe AllowOlder
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RelaxDeps -> AllowOlder
AllowOlder Maybe RelaxDeps
v})
    (String
-> ReadE (Maybe RelaxDeps)
-> Maybe RelaxDeps
-> (Maybe RelaxDeps -> [Maybe String])
-> MkOptDescr
     (ConfigExFlags -> Maybe RelaxDeps)
     (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> b
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg String
"DEPS"
     ((ParseError -> String)
-> ParsecParser (Maybe RelaxDeps) -> ReadE (Maybe RelaxDeps)
forall a. (ParseError -> String) -> ParsecParser a -> ReadE a
parsecToReadEErr ParseError -> String
unexpectMsgString  ParsecParser (Maybe RelaxDeps)
forall (m :: * -> *). CabalParsing m => m (Maybe RelaxDeps)
relaxDepsParser)
     (RelaxDeps -> Maybe RelaxDeps
forall a. a -> Maybe a
Just RelaxDeps
RelaxDepsAll) Maybe RelaxDeps -> [Maybe String]
relaxDepsPrinter)

  , String
-> [String]
-> String
-> (ConfigExFlags -> Maybe RelaxDeps)
-> (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> Maybe RelaxDeps)
     (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"allow-newer"]
    (String
"Ignore upper bounds in all dependencies or DEPS")
    ((AllowNewer -> RelaxDeps) -> Maybe AllowNewer -> Maybe RelaxDeps
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AllowNewer -> RelaxDeps
unAllowNewer (Maybe AllowNewer -> Maybe RelaxDeps)
-> (ConfigExFlags -> Maybe AllowNewer)
-> ConfigExFlags
-> Maybe RelaxDeps
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfigExFlags -> Maybe AllowNewer
configAllowNewer)
    (\Maybe RelaxDeps
v ConfigExFlags
flags -> ConfigExFlags
flags { configAllowNewer :: Maybe AllowNewer
configAllowNewer = (RelaxDeps -> AllowNewer) -> Maybe RelaxDeps -> Maybe AllowNewer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RelaxDeps -> AllowNewer
AllowNewer Maybe RelaxDeps
v})
    (String
-> ReadE (Maybe RelaxDeps)
-> Maybe RelaxDeps
-> (Maybe RelaxDeps -> [Maybe String])
-> MkOptDescr
     (ConfigExFlags -> Maybe RelaxDeps)
     (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> b
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg String
"DEPS"
     ((ParseError -> String)
-> ParsecParser (Maybe RelaxDeps) -> ReadE (Maybe RelaxDeps)
forall a. (ParseError -> String) -> ParsecParser a -> ReadE a
parsecToReadEErr ParseError -> String
unexpectMsgString  ParsecParser (Maybe RelaxDeps)
forall (m :: * -> *). CabalParsing m => m (Maybe RelaxDeps)
relaxDepsParser)
     (RelaxDeps -> Maybe RelaxDeps
forall a. a -> Maybe a
Just RelaxDeps
RelaxDepsAll) Maybe RelaxDeps -> [Maybe String]
relaxDepsPrinter)

  , String
-> [String]
-> String
-> (ConfigExFlags -> Flag WriteGhcEnvironmentFilesPolicy)
-> (Flag WriteGhcEnvironmentFilesPolicy
    -> ConfigExFlags -> ConfigExFlags)
-> MkOptDescr
     (ConfigExFlags -> Flag WriteGhcEnvironmentFilesPolicy)
     (Flag WriteGhcEnvironmentFilesPolicy
      -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
-> OptionField ConfigExFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"write-ghc-environment-files"]
    (String
"Whether to create a .ghc.environment file after a successful build"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" (v2-build only)")
    ConfigExFlags -> Flag WriteGhcEnvironmentFilesPolicy
configWriteGhcEnvironmentFilesPolicy
    (\Flag WriteGhcEnvironmentFilesPolicy
v ConfigExFlags
flags -> ConfigExFlags
flags { configWriteGhcEnvironmentFilesPolicy :: Flag WriteGhcEnvironmentFilesPolicy
configWriteGhcEnvironmentFilesPolicy = Flag WriteGhcEnvironmentFilesPolicy
v})
    (String
-> ReadE (Flag WriteGhcEnvironmentFilesPolicy)
-> (Flag WriteGhcEnvironmentFilesPolicy -> [String])
-> MkOptDescr
     (ConfigExFlags -> Flag WriteGhcEnvironmentFilesPolicy)
     (Flag WriteGhcEnvironmentFilesPolicy
      -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"always|never|ghc8.4.4+"
     ReadE (Flag WriteGhcEnvironmentFilesPolicy)
writeGhcEnvironmentFilesPolicyParser
     Flag WriteGhcEnvironmentFilesPolicy -> [String]
writeGhcEnvironmentFilesPolicyPrinter)
  ]


writeGhcEnvironmentFilesPolicyParser :: ReadE (Flag WriteGhcEnvironmentFilesPolicy)
writeGhcEnvironmentFilesPolicyParser :: ReadE (Flag WriteGhcEnvironmentFilesPolicy)
writeGhcEnvironmentFilesPolicyParser = (String -> Either String (Flag WriteGhcEnvironmentFilesPolicy))
-> ReadE (Flag WriteGhcEnvironmentFilesPolicy)
forall a. (String -> Either String a) -> ReadE a
ReadE ((String -> Either String (Flag WriteGhcEnvironmentFilesPolicy))
 -> ReadE (Flag WriteGhcEnvironmentFilesPolicy))
-> (String -> Either String (Flag WriteGhcEnvironmentFilesPolicy))
-> ReadE (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. (a -> b) -> a -> b
$ \case
  String
"always"    -> Flag WriteGhcEnvironmentFilesPolicy
-> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. b -> Either a b
Right (Flag WriteGhcEnvironmentFilesPolicy
 -> Either String (Flag WriteGhcEnvironmentFilesPolicy))
-> Flag WriteGhcEnvironmentFilesPolicy
-> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. (a -> b) -> a -> b
$ WriteGhcEnvironmentFilesPolicy
-> Flag WriteGhcEnvironmentFilesPolicy
forall a. a -> Flag a
Flag WriteGhcEnvironmentFilesPolicy
AlwaysWriteGhcEnvironmentFiles
  String
"never"     -> Flag WriteGhcEnvironmentFilesPolicy
-> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. b -> Either a b
Right (Flag WriteGhcEnvironmentFilesPolicy
 -> Either String (Flag WriteGhcEnvironmentFilesPolicy))
-> Flag WriteGhcEnvironmentFilesPolicy
-> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. (a -> b) -> a -> b
$ WriteGhcEnvironmentFilesPolicy
-> Flag WriteGhcEnvironmentFilesPolicy
forall a. a -> Flag a
Flag WriteGhcEnvironmentFilesPolicy
NeverWriteGhcEnvironmentFiles
  String
"ghc8.4.4+" -> Flag WriteGhcEnvironmentFilesPolicy
-> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. b -> Either a b
Right (Flag WriteGhcEnvironmentFilesPolicy
 -> Either String (Flag WriteGhcEnvironmentFilesPolicy))
-> Flag WriteGhcEnvironmentFilesPolicy
-> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. (a -> b) -> a -> b
$ WriteGhcEnvironmentFilesPolicy
-> Flag WriteGhcEnvironmentFilesPolicy
forall a. a -> Flag a
Flag WriteGhcEnvironmentFilesPolicy
WriteGhcEnvironmentFilesOnlyForGhc844AndNewer
  String
policy      -> String -> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. a -> Either a b
Left  (String -> Either String (Flag WriteGhcEnvironmentFilesPolicy))
-> String -> Either String (Flag WriteGhcEnvironmentFilesPolicy)
forall a b. (a -> b) -> a -> b
$ String
"Cannot parse the GHC environment file write policy '"
                 String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
policy String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"'"

writeGhcEnvironmentFilesPolicyPrinter
  :: Flag WriteGhcEnvironmentFilesPolicy -> [String]
writeGhcEnvironmentFilesPolicyPrinter :: Flag WriteGhcEnvironmentFilesPolicy -> [String]
writeGhcEnvironmentFilesPolicyPrinter = \case
  (Flag WriteGhcEnvironmentFilesPolicy
AlwaysWriteGhcEnvironmentFiles)                -> [String
"always"]
  (Flag WriteGhcEnvironmentFilesPolicy
NeverWriteGhcEnvironmentFiles)                 -> [String
"never"]
  (Flag WriteGhcEnvironmentFilesPolicy
WriteGhcEnvironmentFilesOnlyForGhc844AndNewer) -> [String
"ghc8.4.4+"]
  Flag WriteGhcEnvironmentFilesPolicy
NoFlag                                               -> []


relaxDepsParser :: CabalParsing m => m (Maybe RelaxDeps)
relaxDepsParser :: m (Maybe RelaxDeps)
relaxDepsParser = do
  [RelaxedDep]
rs <- m RelaxedDep -> m Char -> m [RelaxedDep]
forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
P.sepBy m RelaxedDep
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec (Char -> m Char
forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
',')
  if [RelaxedDep] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [RelaxedDep]
rs
    then String -> m (Maybe RelaxDeps)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> m (Maybe RelaxDeps)) -> String -> m (Maybe RelaxDeps)
forall a b. (a -> b) -> a -> b
$ String
"empty argument list is not allowed. "
             String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Note: use --allow-newer without the equals sign to permit all "
             String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"packages to use newer versions."
    else Maybe RelaxDeps -> m (Maybe RelaxDeps)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe RelaxDeps -> m (Maybe RelaxDeps))
-> ([RelaxedDep] -> Maybe RelaxDeps)
-> [RelaxedDep]
-> m (Maybe RelaxDeps)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelaxDeps -> Maybe RelaxDeps
forall a. a -> Maybe a
Just (RelaxDeps -> Maybe RelaxDeps)
-> ([RelaxedDep] -> RelaxDeps) -> [RelaxedDep] -> Maybe RelaxDeps
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RelaxedDep] -> RelaxDeps
RelaxDepsSome ([RelaxedDep] -> RelaxDeps)
-> ([RelaxedDep] -> [RelaxedDep]) -> [RelaxedDep] -> RelaxDeps
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RelaxedDep] -> [RelaxedDep]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList ([RelaxedDep] -> m (Maybe RelaxDeps))
-> [RelaxedDep] -> m (Maybe RelaxDeps)
forall a b. (a -> b) -> a -> b
$ [RelaxedDep]
rs

relaxDepsPrinter :: (Maybe RelaxDeps) -> [Maybe String]
relaxDepsPrinter :: Maybe RelaxDeps -> [Maybe String]
relaxDepsPrinter Maybe RelaxDeps
Nothing                     = []
relaxDepsPrinter (Just RelaxDeps
RelaxDepsAll)         = [Maybe String
forall a. Maybe a
Nothing]
relaxDepsPrinter (Just (RelaxDepsSome [RelaxedDep]
pkgs)) = (RelaxedDep -> Maybe String) -> [RelaxedDep] -> [Maybe String]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String)
-> (RelaxedDep -> String) -> RelaxedDep -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelaxedDep -> String
forall a. Pretty a => a -> String
prettyShow) ([RelaxedDep] -> [Maybe String]) -> [RelaxedDep] -> [Maybe String]
forall a b. (a -> b) -> a -> b
$ [RelaxedDep]
pkgs


instance Monoid ConfigExFlags where
  mempty :: ConfigExFlags
mempty = ConfigExFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: ConfigExFlags -> ConfigExFlags -> ConfigExFlags
mappend = ConfigExFlags -> ConfigExFlags -> ConfigExFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup ConfigExFlags where
  <> :: ConfigExFlags -> ConfigExFlags -> ConfigExFlags
(<>) = ConfigExFlags -> ConfigExFlags -> ConfigExFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

reconfigureCommand :: CommandUI (ConfigFlags, ConfigExFlags)
reconfigureCommand :: CommandUI (ConfigFlags, ConfigExFlags)
reconfigureCommand
  = CommandUI (ConfigFlags, ConfigExFlags)
configureExCommand
    { commandName :: String
commandName         = String
"reconfigure"
    , commandSynopsis :: String
commandSynopsis     = String
"Reconfigure the package if necessary."
    , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Run `configure` with the most recently used flags, or append FLAGS "
         String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"to the most recently used configuration. "
         String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Accepts the same flags as `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-configure'. "
         String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If the package has never been configured, the default flags are "
         String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"used."
    , commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
        String
"Examples:\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-reconfigure\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Configure with the most recently used flags.\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-reconfigure -w PATH\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Reconfigure with the most recently used flags,\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    but use the compiler at PATH.\n\n"
    , commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"v1-reconfigure" [ String
"[FLAGS]" ]
    , commandDefaultFlags :: (ConfigFlags, ConfigExFlags)
commandDefaultFlags = (ConfigFlags, ConfigExFlags)
forall a. Monoid a => a
mempty
    }

-- ------------------------------------------------------------
-- * Build flags
-- ------------------------------------------------------------

buildCommand :: CommandUI BuildFlags
buildCommand :: CommandUI BuildFlags
buildCommand = CommandUI BuildFlags
parent {
    commandName :: String
commandName = String
"build",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
      String
"Components encompass executables, tests, and benchmarks.\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Affected by configuration options, see `v1-configure`.\n",
    commandDefaultFlags :: BuildFlags
commandDefaultFlags = CommandUI BuildFlags -> BuildFlags
forall flags. CommandUI flags -> flags
commandDefaultFlags CommandUI BuildFlags
parent,
    commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"v1-build" ([String] -> String -> String) -> [String] -> String -> String
forall a b. (a -> b) -> a -> b
$
      [ String
"[FLAGS]", String
"COMPONENTS [FLAGS]" ],
    commandOptions :: ShowOrParseArgs -> [OptionField BuildFlags]
commandOptions      = CommandUI BuildFlags -> ShowOrParseArgs -> [OptionField BuildFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI BuildFlags
parent
    , commandNotes :: Maybe (String -> String)
commandNotes      = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
      String
"Examples:\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-build           "
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    All the components in the package\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-build foo       "
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    A component (i.e. lib, exe, test suite)\n\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ ProgramDb -> String
Cabal.programFlagsDescription ProgramDb
defaultProgramDb
  }
  where
    parent :: CommandUI BuildFlags
parent = ProgramDb -> CommandUI BuildFlags
Cabal.buildCommand ProgramDb
defaultProgramDb

-- ------------------------------------------------------------
-- * Test flags
-- ------------------------------------------------------------

-- | Given some 'TestFlags' for the version of Cabal that
-- cabal-install was built with, and a target older 'Version' of
-- Cabal that we want to pass these flags to, convert the
-- flags into a form that will be accepted by the older
-- Setup script.  Generally speaking, this just means filtering
-- out flags that the old Cabal library doesn't understand, but
-- in some cases it may also mean "emulating" a feature using
-- some more legacy flags.
filterTestFlags :: TestFlags -> Version -> TestFlags
filterTestFlags :: TestFlags -> Version -> TestFlags
filterTestFlags TestFlags
flags Version
cabalLibVersion
  -- NB: we expect the latest version to be the most common case,
  -- so test it first.
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int] -> Version
mkVersion [Int
3,Int
0,Int
0] = TestFlags
flags_latest
  -- The naming convention is that flags_version gives flags with
  -- all flags *introduced* in version eliminated.
  -- It is NOT the latest version of Cabal library that
  -- these flags work for; version of introduction is a more
  -- natural metric.
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
<  [Int] -> Version
mkVersion [Int
3,Int
0,Int
0] = TestFlags
flags_3_0_0
  | Bool
otherwise = String -> TestFlags
forall a. HasCallStack => String -> a
error String
"the impossible just happened" -- see first guard
  where
    flags_latest :: TestFlags
flags_latest = TestFlags
flags
    flags_3_0_0 :: TestFlags
flags_3_0_0  = TestFlags
flags_latest {
      -- Cabal < 3.0 doesn't know about --test-wrapper
      testWrapper :: Flag String
Cabal.testWrapper = Flag String
forall a. Flag a
NoFlag
      }

-- ------------------------------------------------------------
-- * Repl command
-- ------------------------------------------------------------

replCommand :: CommandUI ReplFlags
replCommand :: CommandUI ReplFlags
replCommand = CommandUI ReplFlags
parent {
    commandName :: String
commandName = String
"repl",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"If the current directory contains no package, ignores COMPONENT "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"parameters and opens an interactive interpreter session;\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Otherwise, (re)configures with the given or default flags, and "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"loads the interpreter with the relevant modules. For executables, "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"tests and benchmarks, loads the main module (and its "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"dependencies); for libraries all exposed/other modules.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"The default component is the library itself, or the executable "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"if that is the only component.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Support for loading specific modules is planned but not "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"implemented yet. For certain scenarios, `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-exec -- ghci :l Foo` may be used instead. Note that `v1-exec` will "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"not (re)configure and you will have to specify the location of "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"other modules, if required.\n",
    commandUsage :: String -> String
commandUsage =  \String
pname -> String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-repl [COMPONENT] [FLAGS]\n",
    commandDefaultFlags :: ReplFlags
commandDefaultFlags = CommandUI ReplFlags -> ReplFlags
forall flags. CommandUI flags -> flags
commandDefaultFlags CommandUI ReplFlags
parent,
    commandOptions :: ShowOrParseArgs -> [OptionField ReplFlags]
commandOptions      = CommandUI ReplFlags -> ShowOrParseArgs -> [OptionField ReplFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI ReplFlags
parent,
    commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
      String
"Examples:\n"
    String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-repl           "
    String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    The first component in the package\n"
    String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-repl foo       "
    String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    A named component (i.e. lib, exe, test suite)\n"
    String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-repl --ghc-options=\"-lstdc++\""
    String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  Specifying flags for interpreter\n"
  }
  where
    parent :: CommandUI ReplFlags
parent = ProgramDb -> CommandUI ReplFlags
Cabal.replCommand ProgramDb
defaultProgramDb

-- ------------------------------------------------------------
-- * Test command
-- ------------------------------------------------------------

testCommand :: CommandUI (BuildFlags, TestFlags)
testCommand :: CommandUI (BuildFlags, TestFlags)
testCommand = CommandUI TestFlags
parent {
  commandName :: String
commandName = String
"test",
  commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"If necessary (re)configures with `--enable-tests` flag and builds"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" the test suite.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Remember that the tests' dependencies must be installed if there"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" are additional ones; e.g. with `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-install --only-dependencies --enable-tests`.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"By defining UserHooks in a custom Setup.hs, the package can"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" define actions to be executed before and after running tests.\n",
  commandUsage :: String -> String
commandUsage = String -> [String] -> String -> String
usageAlternatives String
"v1-test"
      [ String
"[FLAGS]", String
"TESTCOMPONENTS [FLAGS]" ],
  commandDefaultFlags :: (BuildFlags, TestFlags)
commandDefaultFlags = (BuildFlags
Cabal.defaultBuildFlags, CommandUI TestFlags -> TestFlags
forall flags. CommandUI flags -> flags
commandDefaultFlags CommandUI TestFlags
parent),
  commandOptions :: ShowOrParseArgs -> [OptionField (BuildFlags, TestFlags)]
commandOptions      =
    \ShowOrParseArgs
showOrParseArgs -> ((BuildFlags, TestFlags) -> BuildFlags)
-> (BuildFlags
    -> (BuildFlags, TestFlags) -> (BuildFlags, TestFlags))
-> [OptionField BuildFlags]
-> [OptionField (BuildFlags, TestFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (BuildFlags, TestFlags) -> BuildFlags
forall a b. (a, b) -> a
get1 BuildFlags -> (BuildFlags, TestFlags) -> (BuildFlags, TestFlags)
forall a a b. a -> (a, b) -> (a, b)
set1
                        (ProgramDb -> ShowOrParseArgs -> [OptionField BuildFlags]
Cabal.buildOptions ProgramDb
progDb ShowOrParseArgs
showOrParseArgs)
                        [OptionField (BuildFlags, TestFlags)]
-> [OptionField (BuildFlags, TestFlags)]
-> [OptionField (BuildFlags, TestFlags)]
forall a. [a] -> [a] -> [a]
++
                        ((BuildFlags, TestFlags) -> TestFlags)
-> (TestFlags
    -> (BuildFlags, TestFlags) -> (BuildFlags, TestFlags))
-> [OptionField TestFlags]
-> [OptionField (BuildFlags, TestFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (BuildFlags, TestFlags) -> TestFlags
forall a b. (a, b) -> b
get2 TestFlags -> (BuildFlags, TestFlags) -> (BuildFlags, TestFlags)
forall b a b. b -> (a, b) -> (a, b)
set2
                        (CommandUI TestFlags -> ShowOrParseArgs -> [OptionField TestFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI TestFlags
parent ShowOrParseArgs
showOrParseArgs)
  }
  where
    get1 :: (a, b) -> a
get1 (a
a,b
_) = a
a; set1 :: a -> (a, b) -> (a, b)
set1 a
a (a
_,b
b) = (a
a,b
b)
    get2 :: (a, b) -> b
get2 (a
_,b
b) = b
b; set2 :: b -> (a, b) -> (a, b)
set2 b
b (a
a,b
_) = (a
a,b
b)

    parent :: CommandUI TestFlags
parent = CommandUI TestFlags
Cabal.testCommand
    progDb :: ProgramDb
progDb = ProgramDb
defaultProgramDb

-- ------------------------------------------------------------
-- * Bench command
-- ------------------------------------------------------------

benchmarkCommand :: CommandUI (BuildFlags, BenchmarkFlags)
benchmarkCommand :: CommandUI (BuildFlags, BenchmarkFlags)
benchmarkCommand = CommandUI BenchmarkFlags
parent {
  commandName :: String
commandName = String
"bench",
  commandUsage :: String -> String
commandUsage = String -> [String] -> String -> String
usageAlternatives String
"v1-bench"
      [ String
"[FLAGS]", String
"BENCHCOMPONENTS [FLAGS]" ],
  commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"If necessary (re)configures with `--enable-benchmarks` flag and"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" builds the benchmarks.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Remember that the benchmarks' dependencies must be installed if"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" there are additional ones; e.g. with `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-install --only-dependencies --enable-benchmarks`.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"By defining UserHooks in a custom Setup.hs, the package can"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" define actions to be executed before and after running"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" benchmarks.\n",
  commandDefaultFlags :: (BuildFlags, BenchmarkFlags)
commandDefaultFlags = (BuildFlags
Cabal.defaultBuildFlags, CommandUI BenchmarkFlags -> BenchmarkFlags
forall flags. CommandUI flags -> flags
commandDefaultFlags CommandUI BenchmarkFlags
parent),
  commandOptions :: ShowOrParseArgs -> [OptionField (BuildFlags, BenchmarkFlags)]
commandOptions      =
    \ShowOrParseArgs
showOrParseArgs -> ((BuildFlags, BenchmarkFlags) -> BuildFlags)
-> (BuildFlags
    -> (BuildFlags, BenchmarkFlags) -> (BuildFlags, BenchmarkFlags))
-> [OptionField BuildFlags]
-> [OptionField (BuildFlags, BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (BuildFlags, BenchmarkFlags) -> BuildFlags
forall a b. (a, b) -> a
get1 BuildFlags
-> (BuildFlags, BenchmarkFlags) -> (BuildFlags, BenchmarkFlags)
forall a a b. a -> (a, b) -> (a, b)
set1
                        (ProgramDb -> ShowOrParseArgs -> [OptionField BuildFlags]
Cabal.buildOptions ProgramDb
progDb ShowOrParseArgs
showOrParseArgs)
                        [OptionField (BuildFlags, BenchmarkFlags)]
-> [OptionField (BuildFlags, BenchmarkFlags)]
-> [OptionField (BuildFlags, BenchmarkFlags)]
forall a. [a] -> [a] -> [a]
++
                        ((BuildFlags, BenchmarkFlags) -> BenchmarkFlags)
-> (BenchmarkFlags
    -> (BuildFlags, BenchmarkFlags) -> (BuildFlags, BenchmarkFlags))
-> [OptionField BenchmarkFlags]
-> [OptionField (BuildFlags, BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (BuildFlags, BenchmarkFlags) -> BenchmarkFlags
forall a b. (a, b) -> b
get2 BenchmarkFlags
-> (BuildFlags, BenchmarkFlags) -> (BuildFlags, BenchmarkFlags)
forall b a b. b -> (a, b) -> (a, b)
set2
                        (CommandUI BenchmarkFlags
-> ShowOrParseArgs -> [OptionField BenchmarkFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI BenchmarkFlags
parent ShowOrParseArgs
showOrParseArgs)
  }
  where
    get1 :: (a, b) -> a
get1 (a
a,b
_) = a
a; set1 :: a -> (a, b) -> (a, b)
set1 a
a (a
_,b
b) = (a
a,b
b)
    get2 :: (a, b) -> b
get2 (a
_,b
b) = b
b; set2 :: b -> (a, b) -> (a, b)
set2 b
b (a
a,b
_) = (a
a,b
b)

    parent :: CommandUI BenchmarkFlags
parent = CommandUI BenchmarkFlags
Cabal.benchmarkCommand
    progDb :: ProgramDb
progDb = ProgramDb
defaultProgramDb

-- ------------------------------------------------------------
-- * Fetch command
-- ------------------------------------------------------------

data FetchFlags = FetchFlags {
--    fetchOutput    :: Flag FilePath,
      FetchFlags -> Flag Bool
fetchDeps      :: Flag Bool,
      FetchFlags -> Flag Bool
fetchDryRun    :: Flag Bool,
      FetchFlags -> Flag PreSolver
fetchSolver           :: Flag PreSolver,
      FetchFlags -> Flag Int
fetchMaxBackjumps     :: Flag Int,
      FetchFlags -> Flag ReorderGoals
fetchReorderGoals     :: Flag ReorderGoals,
      FetchFlags -> Flag CountConflicts
fetchCountConflicts   :: Flag CountConflicts,
      FetchFlags -> Flag FineGrainedConflicts
fetchFineGrainedConflicts :: Flag FineGrainedConflicts,
      FetchFlags -> Flag MinimizeConflictSet
fetchMinimizeConflictSet :: Flag MinimizeConflictSet,
      FetchFlags -> Flag IndependentGoals
fetchIndependentGoals :: Flag IndependentGoals,
      FetchFlags -> Flag ShadowPkgs
fetchShadowPkgs       :: Flag ShadowPkgs,
      FetchFlags -> Flag StrongFlags
fetchStrongFlags      :: Flag StrongFlags,
      FetchFlags -> Flag AllowBootLibInstalls
fetchAllowBootLibInstalls :: Flag AllowBootLibInstalls,
      FetchFlags -> Flag OnlyConstrained
fetchOnlyConstrained  :: Flag OnlyConstrained,
      FetchFlags -> Flag Bool
fetchTests            :: Flag Bool,
      FetchFlags -> Flag Bool
fetchBenchmarks       :: Flag Bool,
      FetchFlags -> Flag Verbosity
fetchVerbosity :: Flag Verbosity
    }

defaultFetchFlags :: FetchFlags
defaultFetchFlags :: FetchFlags
defaultFetchFlags = FetchFlags :: Flag Bool
-> Flag Bool
-> Flag PreSolver
-> Flag Int
-> Flag ReorderGoals
-> Flag CountConflicts
-> Flag FineGrainedConflicts
-> Flag MinimizeConflictSet
-> Flag IndependentGoals
-> Flag ShadowPkgs
-> Flag StrongFlags
-> Flag AllowBootLibInstalls
-> Flag OnlyConstrained
-> Flag Bool
-> Flag Bool
-> Flag Verbosity
-> FetchFlags
FetchFlags {
--  fetchOutput    = mempty,
    fetchDeps :: Flag Bool
fetchDeps      = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
True,
    fetchDryRun :: Flag Bool
fetchDryRun    = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False,
    fetchSolver :: Flag PreSolver
fetchSolver           = PreSolver -> Flag PreSolver
forall a. a -> Flag a
Flag PreSolver
defaultSolver,
    fetchMaxBackjumps :: Flag Int
fetchMaxBackjumps     = Int -> Flag Int
forall a. a -> Flag a
Flag Int
defaultMaxBackjumps,
    fetchReorderGoals :: Flag ReorderGoals
fetchReorderGoals     = ReorderGoals -> Flag ReorderGoals
forall a. a -> Flag a
Flag (Bool -> ReorderGoals
ReorderGoals Bool
False),
    fetchCountConflicts :: Flag CountConflicts
fetchCountConflicts   = CountConflicts -> Flag CountConflicts
forall a. a -> Flag a
Flag (Bool -> CountConflicts
CountConflicts Bool
True),
    fetchFineGrainedConflicts :: Flag FineGrainedConflicts
fetchFineGrainedConflicts = FineGrainedConflicts -> Flag FineGrainedConflicts
forall a. a -> Flag a
Flag (Bool -> FineGrainedConflicts
FineGrainedConflicts Bool
True),
    fetchMinimizeConflictSet :: Flag MinimizeConflictSet
fetchMinimizeConflictSet = MinimizeConflictSet -> Flag MinimizeConflictSet
forall a. a -> Flag a
Flag (Bool -> MinimizeConflictSet
MinimizeConflictSet Bool
False),
    fetchIndependentGoals :: Flag IndependentGoals
fetchIndependentGoals = IndependentGoals -> Flag IndependentGoals
forall a. a -> Flag a
Flag (Bool -> IndependentGoals
IndependentGoals Bool
False),
    fetchShadowPkgs :: Flag ShadowPkgs
fetchShadowPkgs       = ShadowPkgs -> Flag ShadowPkgs
forall a. a -> Flag a
Flag (Bool -> ShadowPkgs
ShadowPkgs Bool
False),
    fetchStrongFlags :: Flag StrongFlags
fetchStrongFlags      = StrongFlags -> Flag StrongFlags
forall a. a -> Flag a
Flag (Bool -> StrongFlags
StrongFlags Bool
False),
    fetchAllowBootLibInstalls :: Flag AllowBootLibInstalls
fetchAllowBootLibInstalls = AllowBootLibInstalls -> Flag AllowBootLibInstalls
forall a. a -> Flag a
Flag (Bool -> AllowBootLibInstalls
AllowBootLibInstalls Bool
False),
    fetchOnlyConstrained :: Flag OnlyConstrained
fetchOnlyConstrained  = OnlyConstrained -> Flag OnlyConstrained
forall a. a -> Flag a
Flag OnlyConstrained
OnlyConstrainedNone,
    fetchTests :: Flag Bool
fetchTests            = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False,
    fetchBenchmarks :: Flag Bool
fetchBenchmarks       = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False,
    fetchVerbosity :: Flag Verbosity
fetchVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal
   }

fetchCommand :: CommandUI FetchFlags
fetchCommand :: CommandUI FetchFlags
fetchCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"fetch",
    commandSynopsis :: String
commandSynopsis     = String
"Downloads packages for later installation.",
    commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"fetch" [ String
"[FLAGS] PACKAGES"
                                                    ],
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ ->
          String
"Note that it currently is not possible to fetch the dependencies for a\n"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"package in the current directory.\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandDefaultFlags :: FetchFlags
commandDefaultFlags = FetchFlags
defaultFetchFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField FetchFlags]
commandOptions      = \ ShowOrParseArgs
showOrParseArgs -> [
         (FetchFlags -> Flag Verbosity)
-> (Flag Verbosity -> FetchFlags -> FetchFlags)
-> OptionField FetchFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity FetchFlags -> Flag Verbosity
fetchVerbosity (\Flag Verbosity
v FetchFlags
flags -> FetchFlags
flags { fetchVerbosity :: Flag Verbosity
fetchVerbosity = Flag Verbosity
v })

--     , option "o" ["output"]
--         "Put the package(s) somewhere specific rather than the usual cache."
--         fetchOutput (\v flags -> flags { fetchOutput = v })
--         (reqArgFlag "PATH")

       , String
-> [String]
-> String
-> (FetchFlags -> Flag Bool)
-> (Flag Bool -> FetchFlags -> FetchFlags)
-> MkOptDescr
     (FetchFlags -> Flag Bool)
     (Flag Bool -> FetchFlags -> FetchFlags)
     FetchFlags
-> OptionField FetchFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"dependencies", String
"deps"]
           String
"Resolve and fetch dependencies (default)"
           FetchFlags -> Flag Bool
fetchDeps (\Flag Bool
v FetchFlags
flags -> FetchFlags
flags { fetchDeps :: Flag Bool
fetchDeps = Flag Bool
v })
           MkOptDescr
  (FetchFlags -> Flag Bool)
  (Flag Bool -> FetchFlags -> FetchFlags)
  FetchFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

       , String
-> [String]
-> String
-> (FetchFlags -> Flag Bool)
-> (Flag Bool -> FetchFlags -> FetchFlags)
-> MkOptDescr
     (FetchFlags -> Flag Bool)
     (Flag Bool -> FetchFlags -> FetchFlags)
     FetchFlags
-> OptionField FetchFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"no-dependencies", String
"no-deps"]
           String
"Ignore dependencies"
           FetchFlags -> Flag Bool
fetchDeps (\Flag Bool
v FetchFlags
flags -> FetchFlags
flags { fetchDeps :: Flag Bool
fetchDeps = Flag Bool
v })
           MkOptDescr
  (FetchFlags -> Flag Bool)
  (Flag Bool -> FetchFlags -> FetchFlags)
  FetchFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
falseArg

       , String
-> [String]
-> String
-> (FetchFlags -> Flag Bool)
-> (Flag Bool -> FetchFlags -> FetchFlags)
-> MkOptDescr
     (FetchFlags -> Flag Bool)
     (Flag Bool -> FetchFlags -> FetchFlags)
     FetchFlags
-> OptionField FetchFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"dry-run"]
           String
"Do not install anything, only print what would be installed."
           FetchFlags -> Flag Bool
fetchDryRun (\Flag Bool
v FetchFlags
flags -> FetchFlags
flags { fetchDryRun :: Flag Bool
fetchDryRun = Flag Bool
v })
           MkOptDescr
  (FetchFlags -> Flag Bool)
  (Flag Bool -> FetchFlags -> FetchFlags)
  FetchFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      , String
-> [String]
-> String
-> (FetchFlags -> Flag Bool)
-> (Flag Bool -> FetchFlags -> FetchFlags)
-> MkOptDescr
     (FetchFlags -> Flag Bool)
     (Flag Bool -> FetchFlags -> FetchFlags)
     FetchFlags
-> OptionField FetchFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"tests"]
         String
"dependency checking and compilation for test suites listed in the package description file."
         FetchFlags -> Flag Bool
fetchTests (\Flag Bool
v FetchFlags
flags -> FetchFlags
flags { fetchTests :: Flag Bool
fetchTests = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (FetchFlags -> Flag Bool)
     (Flag Bool -> FetchFlags -> FetchFlags)
     FetchFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      , String
-> [String]
-> String
-> (FetchFlags -> Flag Bool)
-> (Flag Bool -> FetchFlags -> FetchFlags)
-> MkOptDescr
     (FetchFlags -> Flag Bool)
     (Flag Bool -> FetchFlags -> FetchFlags)
     FetchFlags
-> OptionField FetchFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"benchmarks"]
         String
"dependency checking and compilation for benchmarks listed in the package description file."
         FetchFlags -> Flag Bool
fetchBenchmarks (\Flag Bool
v FetchFlags
flags -> FetchFlags
flags { fetchBenchmarks :: Flag Bool
fetchBenchmarks = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (FetchFlags -> Flag Bool)
     (Flag Bool -> FetchFlags -> FetchFlags)
     FetchFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

       ] [OptionField FetchFlags]
-> [OptionField FetchFlags] -> [OptionField FetchFlags]
forall a. [a] -> [a] -> [a]
++

       (FetchFlags -> Flag PreSolver)
-> (Flag PreSolver -> FetchFlags -> FetchFlags)
-> OptionField FetchFlags
forall flags.
(flags -> Flag PreSolver)
-> (Flag PreSolver -> flags -> flags) -> OptionField flags
optionSolver      FetchFlags -> Flag PreSolver
fetchSolver           (\Flag PreSolver
v FetchFlags
flags -> FetchFlags
flags { fetchSolver :: Flag PreSolver
fetchSolver           = Flag PreSolver
v }) OptionField FetchFlags
-> [OptionField FetchFlags] -> [OptionField FetchFlags]
forall a. a -> [a] -> [a]
:
       ShowOrParseArgs
-> (FetchFlags -> Flag Int)
-> (Flag Int -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag ReorderGoals)
-> (Flag ReorderGoals -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag CountConflicts)
-> (Flag CountConflicts -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag FineGrainedConflicts)
-> (Flag FineGrainedConflicts -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag MinimizeConflictSet)
-> (Flag MinimizeConflictSet -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag IndependentGoals)
-> (Flag IndependentGoals -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag ShadowPkgs)
-> (Flag ShadowPkgs -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag StrongFlags)
-> (Flag StrongFlags -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag AllowBootLibInstalls)
-> (Flag AllowBootLibInstalls -> FetchFlags -> FetchFlags)
-> (FetchFlags -> Flag OnlyConstrained)
-> (Flag OnlyConstrained -> FetchFlags -> FetchFlags)
-> [OptionField FetchFlags]
forall flags.
ShowOrParseArgs
-> (flags -> Flag Int)
-> (Flag Int -> flags -> flags)
-> (flags -> Flag ReorderGoals)
-> (Flag ReorderGoals -> flags -> flags)
-> (flags -> Flag CountConflicts)
-> (Flag CountConflicts -> flags -> flags)
-> (flags -> Flag FineGrainedConflicts)
-> (Flag FineGrainedConflicts -> flags -> flags)
-> (flags -> Flag MinimizeConflictSet)
-> (Flag MinimizeConflictSet -> flags -> flags)
-> (flags -> Flag IndependentGoals)
-> (Flag IndependentGoals -> flags -> flags)
-> (flags -> Flag ShadowPkgs)
-> (Flag ShadowPkgs -> flags -> flags)
-> (flags -> Flag StrongFlags)
-> (Flag StrongFlags -> flags -> flags)
-> (flags -> Flag AllowBootLibInstalls)
-> (Flag AllowBootLibInstalls -> flags -> flags)
-> (flags -> Flag OnlyConstrained)
-> (Flag OnlyConstrained -> flags -> flags)
-> [OptionField flags]
optionSolverFlags ShowOrParseArgs
showOrParseArgs
                         FetchFlags -> Flag Int
fetchMaxBackjumps     (\Flag Int
v FetchFlags
flags -> FetchFlags
flags { fetchMaxBackjumps :: Flag Int
fetchMaxBackjumps     = Flag Int
v })
                         FetchFlags -> Flag ReorderGoals
fetchReorderGoals     (\Flag ReorderGoals
v FetchFlags
flags -> FetchFlags
flags { fetchReorderGoals :: Flag ReorderGoals
fetchReorderGoals     = Flag ReorderGoals
v })
                         FetchFlags -> Flag CountConflicts
fetchCountConflicts   (\Flag CountConflicts
v FetchFlags
flags -> FetchFlags
flags { fetchCountConflicts :: Flag CountConflicts
fetchCountConflicts   = Flag CountConflicts
v })
                         FetchFlags -> Flag FineGrainedConflicts
fetchFineGrainedConflicts (\Flag FineGrainedConflicts
v FetchFlags
flags -> FetchFlags
flags { fetchFineGrainedConflicts :: Flag FineGrainedConflicts
fetchFineGrainedConflicts = Flag FineGrainedConflicts
v })
                         FetchFlags -> Flag MinimizeConflictSet
fetchMinimizeConflictSet (\Flag MinimizeConflictSet
v FetchFlags
flags -> FetchFlags
flags { fetchMinimizeConflictSet :: Flag MinimizeConflictSet
fetchMinimizeConflictSet = Flag MinimizeConflictSet
v })
                         FetchFlags -> Flag IndependentGoals
fetchIndependentGoals (\Flag IndependentGoals
v FetchFlags
flags -> FetchFlags
flags { fetchIndependentGoals :: Flag IndependentGoals
fetchIndependentGoals = Flag IndependentGoals
v })
                         FetchFlags -> Flag ShadowPkgs
fetchShadowPkgs       (\Flag ShadowPkgs
v FetchFlags
flags -> FetchFlags
flags { fetchShadowPkgs :: Flag ShadowPkgs
fetchShadowPkgs       = Flag ShadowPkgs
v })
                         FetchFlags -> Flag StrongFlags
fetchStrongFlags      (\Flag StrongFlags
v FetchFlags
flags -> FetchFlags
flags { fetchStrongFlags :: Flag StrongFlags
fetchStrongFlags      = Flag StrongFlags
v })
                         FetchFlags -> Flag AllowBootLibInstalls
fetchAllowBootLibInstalls (\Flag AllowBootLibInstalls
v FetchFlags
flags -> FetchFlags
flags { fetchAllowBootLibInstalls :: Flag AllowBootLibInstalls
fetchAllowBootLibInstalls = Flag AllowBootLibInstalls
v })
                         FetchFlags -> Flag OnlyConstrained
fetchOnlyConstrained  (\Flag OnlyConstrained
v FetchFlags
flags -> FetchFlags
flags { fetchOnlyConstrained :: Flag OnlyConstrained
fetchOnlyConstrained  = Flag OnlyConstrained
v })

  }

-- ------------------------------------------------------------
-- * Freeze command
-- ------------------------------------------------------------

data FreezeFlags = FreezeFlags {
      FreezeFlags -> Flag Bool
freezeDryRun           :: Flag Bool,
      FreezeFlags -> Flag Bool
freezeTests            :: Flag Bool,
      FreezeFlags -> Flag Bool
freezeBenchmarks       :: Flag Bool,
      FreezeFlags -> Flag PreSolver
freezeSolver           :: Flag PreSolver,
      FreezeFlags -> Flag Int
freezeMaxBackjumps     :: Flag Int,
      FreezeFlags -> Flag ReorderGoals
freezeReorderGoals     :: Flag ReorderGoals,
      FreezeFlags -> Flag CountConflicts
freezeCountConflicts   :: Flag CountConflicts,
      FreezeFlags -> Flag FineGrainedConflicts
freezeFineGrainedConflicts :: Flag FineGrainedConflicts,
      FreezeFlags -> Flag MinimizeConflictSet
freezeMinimizeConflictSet :: Flag MinimizeConflictSet,
      FreezeFlags -> Flag IndependentGoals
freezeIndependentGoals :: Flag IndependentGoals,
      FreezeFlags -> Flag ShadowPkgs
freezeShadowPkgs       :: Flag ShadowPkgs,
      FreezeFlags -> Flag StrongFlags
freezeStrongFlags      :: Flag StrongFlags,
      FreezeFlags -> Flag AllowBootLibInstalls
freezeAllowBootLibInstalls :: Flag AllowBootLibInstalls,
      FreezeFlags -> Flag OnlyConstrained
freezeOnlyConstrained  :: Flag OnlyConstrained,
      FreezeFlags -> Flag Verbosity
freezeVerbosity        :: Flag Verbosity
    }

defaultFreezeFlags :: FreezeFlags
defaultFreezeFlags :: FreezeFlags
defaultFreezeFlags = FreezeFlags :: Flag Bool
-> Flag Bool
-> Flag Bool
-> Flag PreSolver
-> Flag Int
-> Flag ReorderGoals
-> Flag CountConflicts
-> Flag FineGrainedConflicts
-> Flag MinimizeConflictSet
-> Flag IndependentGoals
-> Flag ShadowPkgs
-> Flag StrongFlags
-> Flag AllowBootLibInstalls
-> Flag OnlyConstrained
-> Flag Verbosity
-> FreezeFlags
FreezeFlags {
    freezeDryRun :: Flag Bool
freezeDryRun           = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False,
    freezeTests :: Flag Bool
freezeTests            = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False,
    freezeBenchmarks :: Flag Bool
freezeBenchmarks       = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False,
    freezeSolver :: Flag PreSolver
freezeSolver           = PreSolver -> Flag PreSolver
forall a. a -> Flag a
Flag PreSolver
defaultSolver,
    freezeMaxBackjumps :: Flag Int
freezeMaxBackjumps     = Int -> Flag Int
forall a. a -> Flag a
Flag Int
defaultMaxBackjumps,
    freezeReorderGoals :: Flag ReorderGoals
freezeReorderGoals     = ReorderGoals -> Flag ReorderGoals
forall a. a -> Flag a
Flag (Bool -> ReorderGoals
ReorderGoals Bool
False),
    freezeCountConflicts :: Flag CountConflicts
freezeCountConflicts   = CountConflicts -> Flag CountConflicts
forall a. a -> Flag a
Flag (Bool -> CountConflicts
CountConflicts Bool
True),
    freezeFineGrainedConflicts :: Flag FineGrainedConflicts
freezeFineGrainedConflicts = FineGrainedConflicts -> Flag FineGrainedConflicts
forall a. a -> Flag a
Flag (Bool -> FineGrainedConflicts
FineGrainedConflicts Bool
True),
    freezeMinimizeConflictSet :: Flag MinimizeConflictSet
freezeMinimizeConflictSet = MinimizeConflictSet -> Flag MinimizeConflictSet
forall a. a -> Flag a
Flag (Bool -> MinimizeConflictSet
MinimizeConflictSet Bool
False),
    freezeIndependentGoals :: Flag IndependentGoals
freezeIndependentGoals = IndependentGoals -> Flag IndependentGoals
forall a. a -> Flag a
Flag (Bool -> IndependentGoals
IndependentGoals Bool
False),
    freezeShadowPkgs :: Flag ShadowPkgs
freezeShadowPkgs       = ShadowPkgs -> Flag ShadowPkgs
forall a. a -> Flag a
Flag (Bool -> ShadowPkgs
ShadowPkgs Bool
False),
    freezeStrongFlags :: Flag StrongFlags
freezeStrongFlags      = StrongFlags -> Flag StrongFlags
forall a. a -> Flag a
Flag (Bool -> StrongFlags
StrongFlags Bool
False),
    freezeAllowBootLibInstalls :: Flag AllowBootLibInstalls
freezeAllowBootLibInstalls = AllowBootLibInstalls -> Flag AllowBootLibInstalls
forall a. a -> Flag a
Flag (Bool -> AllowBootLibInstalls
AllowBootLibInstalls Bool
False),
    freezeOnlyConstrained :: Flag OnlyConstrained
freezeOnlyConstrained  = OnlyConstrained -> Flag OnlyConstrained
forall a. a -> Flag a
Flag OnlyConstrained
OnlyConstrainedNone,
    freezeVerbosity :: Flag Verbosity
freezeVerbosity        = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal
   }

freezeCommand :: CommandUI FreezeFlags
freezeCommand :: CommandUI FreezeFlags
freezeCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"freeze",
    commandSynopsis :: String
commandSynopsis     = String
"Freeze dependencies.",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Calculates a valid set of dependencies and their exact versions. "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If successful, saves the result to the file `cabal.config`.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"The package versions specified in `cabal.config` will be used for "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"any future installs.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"An existing `cabal.config` is ignored and overwritten.\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandUsage :: String -> String
commandUsage        = String -> String -> String
usageFlags String
"freeze",
    commandDefaultFlags :: FreezeFlags
commandDefaultFlags = FreezeFlags
defaultFreezeFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField FreezeFlags]
commandOptions      = \ ShowOrParseArgs
showOrParseArgs -> [
         (FreezeFlags -> Flag Verbosity)
-> (Flag Verbosity -> FreezeFlags -> FreezeFlags)
-> OptionField FreezeFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity FreezeFlags -> Flag Verbosity
freezeVerbosity
         (\Flag Verbosity
v FreezeFlags
flags -> FreezeFlags
flags { freezeVerbosity :: Flag Verbosity
freezeVerbosity = Flag Verbosity
v })

       , String
-> [String]
-> String
-> (FreezeFlags -> Flag Bool)
-> (Flag Bool -> FreezeFlags -> FreezeFlags)
-> MkOptDescr
     (FreezeFlags -> Flag Bool)
     (Flag Bool -> FreezeFlags -> FreezeFlags)
     FreezeFlags
-> OptionField FreezeFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"dry-run"]
           String
"Do not freeze anything, only print what would be frozen"
           FreezeFlags -> Flag Bool
freezeDryRun (\Flag Bool
v FreezeFlags
flags -> FreezeFlags
flags { freezeDryRun :: Flag Bool
freezeDryRun = Flag Bool
v })
           MkOptDescr
  (FreezeFlags -> Flag Bool)
  (Flag Bool -> FreezeFlags -> FreezeFlags)
  FreezeFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

       , String
-> [String]
-> String
-> (FreezeFlags -> Flag Bool)
-> (Flag Bool -> FreezeFlags -> FreezeFlags)
-> MkOptDescr
     (FreezeFlags -> Flag Bool)
     (Flag Bool -> FreezeFlags -> FreezeFlags)
     FreezeFlags
-> OptionField FreezeFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"tests"]
           (String
"freezing of the dependencies of any tests suites "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"in the package description file.")
           FreezeFlags -> Flag Bool
freezeTests (\Flag Bool
v FreezeFlags
flags -> FreezeFlags
flags { freezeTests :: Flag Bool
freezeTests = Flag Bool
v })
           (String
-> String
-> MkOptDescr
     (FreezeFlags -> Flag Bool)
     (Flag Bool -> FreezeFlags -> FreezeFlags)
     FreezeFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

       , String
-> [String]
-> String
-> (FreezeFlags -> Flag Bool)
-> (Flag Bool -> FreezeFlags -> FreezeFlags)
-> MkOptDescr
     (FreezeFlags -> Flag Bool)
     (Flag Bool -> FreezeFlags -> FreezeFlags)
     FreezeFlags
-> OptionField FreezeFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"benchmarks"]
           (String
"freezing of the dependencies of any benchmarks suites "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"in the package description file.")
           FreezeFlags -> Flag Bool
freezeBenchmarks (\Flag Bool
v FreezeFlags
flags -> FreezeFlags
flags { freezeBenchmarks :: Flag Bool
freezeBenchmarks = Flag Bool
v })
           (String
-> String
-> MkOptDescr
     (FreezeFlags -> Flag Bool)
     (Flag Bool -> FreezeFlags -> FreezeFlags)
     FreezeFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

       ] [OptionField FreezeFlags]
-> [OptionField FreezeFlags] -> [OptionField FreezeFlags]
forall a. [a] -> [a] -> [a]
++

       (FreezeFlags -> Flag PreSolver)
-> (Flag PreSolver -> FreezeFlags -> FreezeFlags)
-> OptionField FreezeFlags
forall flags.
(flags -> Flag PreSolver)
-> (Flag PreSolver -> flags -> flags) -> OptionField flags
optionSolver
         FreezeFlags -> Flag PreSolver
freezeSolver           (\Flag PreSolver
v FreezeFlags
flags -> FreezeFlags
flags { freezeSolver :: Flag PreSolver
freezeSolver           = Flag PreSolver
v })OptionField FreezeFlags
-> [OptionField FreezeFlags] -> [OptionField FreezeFlags]
forall a. a -> [a] -> [a]
:
       ShowOrParseArgs
-> (FreezeFlags -> Flag Int)
-> (Flag Int -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag ReorderGoals)
-> (Flag ReorderGoals -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag CountConflicts)
-> (Flag CountConflicts -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag FineGrainedConflicts)
-> (Flag FineGrainedConflicts -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag MinimizeConflictSet)
-> (Flag MinimizeConflictSet -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag IndependentGoals)
-> (Flag IndependentGoals -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag ShadowPkgs)
-> (Flag ShadowPkgs -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag StrongFlags)
-> (Flag StrongFlags -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag AllowBootLibInstalls)
-> (Flag AllowBootLibInstalls -> FreezeFlags -> FreezeFlags)
-> (FreezeFlags -> Flag OnlyConstrained)
-> (Flag OnlyConstrained -> FreezeFlags -> FreezeFlags)
-> [OptionField FreezeFlags]
forall flags.
ShowOrParseArgs
-> (flags -> Flag Int)
-> (Flag Int -> flags -> flags)
-> (flags -> Flag ReorderGoals)
-> (Flag ReorderGoals -> flags -> flags)
-> (flags -> Flag CountConflicts)
-> (Flag CountConflicts -> flags -> flags)
-> (flags -> Flag FineGrainedConflicts)
-> (Flag FineGrainedConflicts -> flags -> flags)
-> (flags -> Flag MinimizeConflictSet)
-> (Flag MinimizeConflictSet -> flags -> flags)
-> (flags -> Flag IndependentGoals)
-> (Flag IndependentGoals -> flags -> flags)
-> (flags -> Flag ShadowPkgs)
-> (Flag ShadowPkgs -> flags -> flags)
-> (flags -> Flag StrongFlags)
-> (Flag StrongFlags -> flags -> flags)
-> (flags -> Flag AllowBootLibInstalls)
-> (Flag AllowBootLibInstalls -> flags -> flags)
-> (flags -> Flag OnlyConstrained)
-> (Flag OnlyConstrained -> flags -> flags)
-> [OptionField flags]
optionSolverFlags ShowOrParseArgs
showOrParseArgs
                         FreezeFlags -> Flag Int
freezeMaxBackjumps     (\Flag Int
v FreezeFlags
flags -> FreezeFlags
flags { freezeMaxBackjumps :: Flag Int
freezeMaxBackjumps     = Flag Int
v })
                         FreezeFlags -> Flag ReorderGoals
freezeReorderGoals     (\Flag ReorderGoals
v FreezeFlags
flags -> FreezeFlags
flags { freezeReorderGoals :: Flag ReorderGoals
freezeReorderGoals     = Flag ReorderGoals
v })
                         FreezeFlags -> Flag CountConflicts
freezeCountConflicts   (\Flag CountConflicts
v FreezeFlags
flags -> FreezeFlags
flags { freezeCountConflicts :: Flag CountConflicts
freezeCountConflicts   = Flag CountConflicts
v })
                         FreezeFlags -> Flag FineGrainedConflicts
freezeFineGrainedConflicts (\Flag FineGrainedConflicts
v FreezeFlags
flags -> FreezeFlags
flags { freezeFineGrainedConflicts :: Flag FineGrainedConflicts
freezeFineGrainedConflicts = Flag FineGrainedConflicts
v })
                         FreezeFlags -> Flag MinimizeConflictSet
freezeMinimizeConflictSet (\Flag MinimizeConflictSet
v FreezeFlags
flags -> FreezeFlags
flags { freezeMinimizeConflictSet :: Flag MinimizeConflictSet
freezeMinimizeConflictSet = Flag MinimizeConflictSet
v })
                         FreezeFlags -> Flag IndependentGoals
freezeIndependentGoals (\Flag IndependentGoals
v FreezeFlags
flags -> FreezeFlags
flags { freezeIndependentGoals :: Flag IndependentGoals
freezeIndependentGoals = Flag IndependentGoals
v })
                         FreezeFlags -> Flag ShadowPkgs
freezeShadowPkgs       (\Flag ShadowPkgs
v FreezeFlags
flags -> FreezeFlags
flags { freezeShadowPkgs :: Flag ShadowPkgs
freezeShadowPkgs       = Flag ShadowPkgs
v })
                         FreezeFlags -> Flag StrongFlags
freezeStrongFlags      (\Flag StrongFlags
v FreezeFlags
flags -> FreezeFlags
flags { freezeStrongFlags :: Flag StrongFlags
freezeStrongFlags      = Flag StrongFlags
v })
                         FreezeFlags -> Flag AllowBootLibInstalls
freezeAllowBootLibInstalls (\Flag AllowBootLibInstalls
v FreezeFlags
flags -> FreezeFlags
flags { freezeAllowBootLibInstalls :: Flag AllowBootLibInstalls
freezeAllowBootLibInstalls = Flag AllowBootLibInstalls
v })
                         FreezeFlags -> Flag OnlyConstrained
freezeOnlyConstrained  (\Flag OnlyConstrained
v FreezeFlags
flags -> FreezeFlags
flags { freezeOnlyConstrained :: Flag OnlyConstrained
freezeOnlyConstrained  = Flag OnlyConstrained
v })

  }

-- ------------------------------------------------------------
-- * 'gen-bounds' command
-- ------------------------------------------------------------

genBoundsCommand :: CommandUI FreezeFlags
genBoundsCommand :: CommandUI FreezeFlags
genBoundsCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"gen-bounds",
    commandSynopsis :: String
commandSynopsis     = String
"Generate dependency bounds.",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Generates bounds for all dependencies that do not currently have them. "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Generated bounds are printed to stdout.  "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"You can then paste them into your .cabal file.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandUsage :: String -> String
commandUsage        = String -> String -> String
usageFlags String
"gen-bounds",
    commandDefaultFlags :: FreezeFlags
commandDefaultFlags = FreezeFlags
defaultFreezeFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField FreezeFlags]
commandOptions      = \ ShowOrParseArgs
_ -> [
     (FreezeFlags -> Flag Verbosity)
-> (Flag Verbosity -> FreezeFlags -> FreezeFlags)
-> OptionField FreezeFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity FreezeFlags -> Flag Verbosity
freezeVerbosity (\Flag Verbosity
v FreezeFlags
flags -> FreezeFlags
flags { freezeVerbosity :: Flag Verbosity
freezeVerbosity = Flag Verbosity
v })
     ]
  }

-- ------------------------------------------------------------
-- * Update command
-- ------------------------------------------------------------

data UpdateFlags
    = UpdateFlags {
        UpdateFlags -> Flag Verbosity
updateVerbosity  :: Flag Verbosity,
        UpdateFlags -> Flag TotalIndexState
updateIndexState :: Flag TotalIndexState
    } deriving (forall x. UpdateFlags -> Rep UpdateFlags x)
-> (forall x. Rep UpdateFlags x -> UpdateFlags)
-> Generic UpdateFlags
forall x. Rep UpdateFlags x -> UpdateFlags
forall x. UpdateFlags -> Rep UpdateFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFlags x -> UpdateFlags
$cfrom :: forall x. UpdateFlags -> Rep UpdateFlags x
Generic

defaultUpdateFlags :: UpdateFlags
defaultUpdateFlags :: UpdateFlags
defaultUpdateFlags
    = UpdateFlags :: Flag Verbosity -> Flag TotalIndexState -> UpdateFlags
UpdateFlags {
        updateVerbosity :: Flag Verbosity
updateVerbosity  = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal,
        updateIndexState :: Flag TotalIndexState
updateIndexState = TotalIndexState -> Flag TotalIndexState
forall a. a -> Flag a
toFlag TotalIndexState
headTotalIndexState
    }

-- ------------------------------------------------------------
-- * Other commands
-- ------------------------------------------------------------

cleanCommand :: CommandUI CleanFlags
cleanCommand :: CommandUI CleanFlags
cleanCommand = CommandUI CleanFlags
Cabal.cleanCommand
  { commandUsage :: String -> String
commandUsage = \String
pname ->
    String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-clean [FLAGS]\n"
  }

checkCommand  :: CommandUI (Flag Verbosity)
checkCommand :: CommandUI (Flag Verbosity)
checkCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"check",
    commandSynopsis :: String
commandSynopsis     = String
"Check the package for common mistakes.",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Expects a .cabal package file in the current directory.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"The checks correspond to the requirements to packages on Hackage. "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If no errors and warnings are reported, Hackage will accept this "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"package.\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandUsage :: String -> String
commandUsage        = String -> String -> String
usageFlags String
"check",
    commandDefaultFlags :: Flag Verbosity
commandDefaultFlags = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal,
    commandOptions :: ShowOrParseArgs -> [OptionField (Flag Verbosity)]
commandOptions      = \ShowOrParseArgs
_ -> [(Flag Verbosity -> Flag Verbosity)
-> (Flag Verbosity -> Flag Verbosity -> Flag Verbosity)
-> OptionField (Flag Verbosity)
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity Flag Verbosity -> Flag Verbosity
forall a. a -> a
id Flag Verbosity -> Flag Verbosity -> Flag Verbosity
forall a b. a -> b -> a
const]
  }

formatCommand  :: CommandUI (Flag Verbosity)
formatCommand :: CommandUI (Flag Verbosity)
formatCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"format",
    commandSynopsis :: String
commandSynopsis     = String
"Reformat the .cabal file using the standard style.",
    commandDescription :: Maybe (String -> String)
commandDescription  = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"format" [String
"[FILE]"],
    commandDefaultFlags :: Flag Verbosity
commandDefaultFlags = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal,
    commandOptions :: ShowOrParseArgs -> [OptionField (Flag Verbosity)]
commandOptions      = \ShowOrParseArgs
_ -> []
  }

manpageCommand :: CommandUI ManpageFlags
manpageCommand :: CommandUI ManpageFlags
manpageCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"man",
    commandSynopsis :: String
commandSynopsis     = String
"Outputs manpage source.",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ ->
      String
"Output manpage source to STDOUT.\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandUsage :: String -> String
commandUsage        = String -> String -> String
usageFlags String
"man",
    commandDefaultFlags :: ManpageFlags
commandDefaultFlags = ManpageFlags
defaultManpageFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField ManpageFlags]
commandOptions      = ShowOrParseArgs -> [OptionField ManpageFlags]
manpageOptions
  }

runCommand :: CommandUI BuildFlags
runCommand :: CommandUI BuildFlags
runCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"run",
    commandSynopsis :: String
commandSynopsis     = String
"Builds and runs an executable.",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Builds and then runs the specified executable. If no executable is "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"specified, but the package contains just one executable, that one "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"is built and executed.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Use `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-test --show-details=streaming` to run a "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"test-suite and get its full output.\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
          String
"Examples:\n"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-run\n"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Run the only executable in the current package;\n"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-run foo -- --fooflag\n"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Works similar to `./foo --fooflag`.\n",
    commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"v1-run"
        [String
"[FLAGS] [EXECUTABLE] [-- EXECUTABLE_FLAGS]"],
    commandDefaultFlags :: BuildFlags
commandDefaultFlags = BuildFlags
forall a. Monoid a => a
mempty,
    commandOptions :: ShowOrParseArgs -> [OptionField BuildFlags]
commandOptions      = CommandUI BuildFlags -> ShowOrParseArgs -> [OptionField BuildFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI BuildFlags
parent
  }
  where
    parent :: CommandUI BuildFlags
parent = ProgramDb -> CommandUI BuildFlags
Cabal.buildCommand ProgramDb
defaultProgramDb

-- ------------------------------------------------------------
-- * Report flags
-- ------------------------------------------------------------

data ReportFlags = ReportFlags {
    ReportFlags -> Flag Username
reportUsername  :: Flag Username,
    ReportFlags -> Flag Password
reportPassword  :: Flag Password,
    ReportFlags -> Flag Verbosity
reportVerbosity :: Flag Verbosity
  } deriving (forall x. ReportFlags -> Rep ReportFlags x)
-> (forall x. Rep ReportFlags x -> ReportFlags)
-> Generic ReportFlags
forall x. Rep ReportFlags x -> ReportFlags
forall x. ReportFlags -> Rep ReportFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReportFlags x -> ReportFlags
$cfrom :: forall x. ReportFlags -> Rep ReportFlags x
Generic

defaultReportFlags :: ReportFlags
defaultReportFlags :: ReportFlags
defaultReportFlags = ReportFlags :: Flag Username -> Flag Password -> Flag Verbosity -> ReportFlags
ReportFlags {
    reportUsername :: Flag Username
reportUsername  = Flag Username
forall a. Monoid a => a
mempty,
    reportPassword :: Flag Password
reportPassword  = Flag Password
forall a. Monoid a => a
mempty,
    reportVerbosity :: Flag Verbosity
reportVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal
  }

reportCommand :: CommandUI ReportFlags
reportCommand :: CommandUI ReportFlags
reportCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"report",
    commandSynopsis :: String
commandSynopsis     = String
"Upload build reports to a remote server.",
    commandDescription :: Maybe (String -> String)
commandDescription  = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ ->
         String
"You can store your Hackage login in the ~/.cabal/config file\n",
    commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"report" [String
"[FLAGS]"],
    commandDefaultFlags :: ReportFlags
commandDefaultFlags = ReportFlags
defaultReportFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField ReportFlags]
commandOptions      = \ShowOrParseArgs
_ ->
      [(ReportFlags -> Flag Verbosity)
-> (Flag Verbosity -> ReportFlags -> ReportFlags)
-> OptionField ReportFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity ReportFlags -> Flag Verbosity
reportVerbosity (\Flag Verbosity
v ReportFlags
flags -> ReportFlags
flags { reportVerbosity :: Flag Verbosity
reportVerbosity = Flag Verbosity
v })

      ,String
-> [String]
-> String
-> (ReportFlags -> Flag Username)
-> (Flag Username -> ReportFlags -> ReportFlags)
-> MkOptDescr
     (ReportFlags -> Flag Username)
     (Flag Username -> ReportFlags -> ReportFlags)
     ReportFlags
-> OptionField ReportFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [Char
'u'] [String
"username"]
        String
"Hackage username."
        ReportFlags -> Flag Username
reportUsername (\Flag Username
v ReportFlags
flags -> ReportFlags
flags { reportUsername :: Flag Username
reportUsername = Flag Username
v })
        (String
-> (String -> Flag Username)
-> (Flag Username -> [String])
-> MkOptDescr
     (ReportFlags -> Flag Username)
     (Flag Username -> ReportFlags -> ReportFlags)
     ReportFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"USERNAME" (Username -> Flag Username
forall a. a -> Flag a
toFlag (Username -> Flag Username)
-> (String -> Username) -> String -> Flag Username
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Username
Username)
                            (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag Username -> Flag String) -> Flag Username -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Username -> String) -> Flag Username -> Flag String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Username -> String
unUsername))

      ,String
-> [String]
-> String
-> (ReportFlags -> Flag Password)
-> (Flag Password -> ReportFlags -> ReportFlags)
-> MkOptDescr
     (ReportFlags -> Flag Password)
     (Flag Password -> ReportFlags -> ReportFlags)
     ReportFlags
-> OptionField ReportFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [Char
'p'] [String
"password"]
        String
"Hackage password."
        ReportFlags -> Flag Password
reportPassword (\Flag Password
v ReportFlags
flags -> ReportFlags
flags { reportPassword :: Flag Password
reportPassword = Flag Password
v })
        (String
-> (String -> Flag Password)
-> (Flag Password -> [String])
-> MkOptDescr
     (ReportFlags -> Flag Password)
     (Flag Password -> ReportFlags -> ReportFlags)
     ReportFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"PASSWORD" (Password -> Flag Password
forall a. a -> Flag a
toFlag (Password -> Flag Password)
-> (String -> Password) -> String -> Flag Password
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Password
Password)
                            (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag Password -> Flag String) -> Flag Password -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Password -> String) -> Flag Password -> Flag String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Password -> String
unPassword))
      ]
  }

instance Monoid ReportFlags where
  mempty :: ReportFlags
mempty = ReportFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: ReportFlags -> ReportFlags -> ReportFlags
mappend = ReportFlags -> ReportFlags -> ReportFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup ReportFlags where
  <> :: ReportFlags -> ReportFlags -> ReportFlags
(<>) = ReportFlags -> ReportFlags -> ReportFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Get flags
-- ------------------------------------------------------------

data GetFlags = GetFlags {
    GetFlags -> Flag String
getDestDir          :: Flag FilePath,
    GetFlags -> Flag Bool
getPristine         :: Flag Bool,
    GetFlags -> Flag TotalIndexState
getIndexState       :: Flag TotalIndexState,
    GetFlags -> Flag ActiveRepos
getActiveRepos      :: Flag ActiveRepos,
    GetFlags -> Flag (Maybe RepoKind)
getSourceRepository :: Flag (Maybe RepoKind),
    GetFlags -> Flag Verbosity
getVerbosity        :: Flag Verbosity
  } deriving (forall x. GetFlags -> Rep GetFlags x)
-> (forall x. Rep GetFlags x -> GetFlags) -> Generic GetFlags
forall x. Rep GetFlags x -> GetFlags
forall x. GetFlags -> Rep GetFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFlags x -> GetFlags
$cfrom :: forall x. GetFlags -> Rep GetFlags x
Generic

defaultGetFlags :: GetFlags
defaultGetFlags :: GetFlags
defaultGetFlags = GetFlags :: Flag String
-> Flag Bool
-> Flag TotalIndexState
-> Flag ActiveRepos
-> Flag (Maybe RepoKind)
-> Flag Verbosity
-> GetFlags
GetFlags {
    getDestDir :: Flag String
getDestDir          = Flag String
forall a. Monoid a => a
mempty,
    getPristine :: Flag Bool
getPristine         = Flag Bool
forall a. Monoid a => a
mempty,
    getIndexState :: Flag TotalIndexState
getIndexState       = Flag TotalIndexState
forall a. Monoid a => a
mempty,
    getActiveRepos :: Flag ActiveRepos
getActiveRepos      = Flag ActiveRepos
forall a. Monoid a => a
mempty,
    getSourceRepository :: Flag (Maybe RepoKind)
getSourceRepository = Flag (Maybe RepoKind)
forall a. Monoid a => a
mempty,
    getVerbosity :: Flag Verbosity
getVerbosity        = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal
   }

getCommand :: CommandUI GetFlags
getCommand :: CommandUI GetFlags
getCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"get",
    commandSynopsis :: String
commandSynopsis     = String
"Download/Extract a package's source code (repository).",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ [String] -> String
unlines [String]
descriptionOfGetCommand,
    commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname -> [String] -> String
unlines ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ String -> String -> [String]
notesOfGetCommand String
"get" String
pname,
    commandUsage :: String -> String
commandUsage        = String -> String -> String
usagePackages String
"get",
    commandDefaultFlags :: GetFlags
commandDefaultFlags = GetFlags
defaultGetFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField GetFlags]
commandOptions      = \ShowOrParseArgs
_ -> [
        (GetFlags -> Flag Verbosity)
-> (Flag Verbosity -> GetFlags -> GetFlags) -> OptionField GetFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity GetFlags -> Flag Verbosity
getVerbosity (\Flag Verbosity
v GetFlags
flags -> GetFlags
flags { getVerbosity :: Flag Verbosity
getVerbosity = Flag Verbosity
v })

       ,String
-> [String]
-> String
-> (GetFlags -> Flag String)
-> (Flag String -> GetFlags -> GetFlags)
-> MkOptDescr
     (GetFlags -> Flag String)
     (Flag String -> GetFlags -> GetFlags)
     GetFlags
-> OptionField GetFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"d" [String
"destdir"]
         String
"Where to place the package source, defaults to the current directory."
         GetFlags -> Flag String
getDestDir (\Flag String
v GetFlags
flags -> GetFlags
flags { getDestDir :: Flag String
getDestDir = Flag String
v })
         (String
-> MkOptDescr
     (GetFlags -> Flag String)
     (Flag String -> GetFlags -> GetFlags)
     GetFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"PATH")

       ,String
-> [String]
-> String
-> (GetFlags -> Flag (Maybe RepoKind))
-> (Flag (Maybe RepoKind) -> GetFlags -> GetFlags)
-> MkOptDescr
     (GetFlags -> Flag (Maybe RepoKind))
     (Flag (Maybe RepoKind) -> GetFlags -> GetFlags)
     GetFlags
-> OptionField GetFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"s" [String
"source-repository"]
         String
"Copy the package's source repository (ie git clone, darcs get, etc as appropriate)."
         GetFlags -> Flag (Maybe RepoKind)
getSourceRepository (\Flag (Maybe RepoKind)
v GetFlags
flags -> GetFlags
flags { getSourceRepository :: Flag (Maybe RepoKind)
getSourceRepository = Flag (Maybe RepoKind)
v })
        (String
-> ReadE (Flag (Maybe RepoKind))
-> Flag (Maybe RepoKind)
-> (Flag (Maybe RepoKind) -> [Maybe String])
-> MkOptDescr
     (GetFlags -> Flag (Maybe RepoKind))
     (Flag (Maybe RepoKind) -> GetFlags -> GetFlags)
     GetFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> b
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg String
"[head|this|...]" ((String -> String)
-> ParsecParser (Flag (Maybe RepoKind))
-> ReadE (Flag (Maybe RepoKind))
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String -> String -> String
forall a b. a -> b -> a
const String
"invalid source-repository")
                                              ((RepoKind -> Flag (Maybe RepoKind))
-> ParsecParser RepoKind -> ParsecParser (Flag (Maybe RepoKind))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Maybe RepoKind -> Flag (Maybe RepoKind)
forall a. a -> Flag a
toFlag (Maybe RepoKind -> Flag (Maybe RepoKind))
-> (RepoKind -> Maybe RepoKind)
-> RepoKind
-> Flag (Maybe RepoKind)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RepoKind -> Maybe RepoKind
forall a. a -> Maybe a
Just) ParsecParser RepoKind
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec))
                                  (Maybe RepoKind -> Flag (Maybe RepoKind)
forall a. a -> Flag a
Flag Maybe RepoKind
forall a. Maybe a
Nothing)
                                  ((Maybe RepoKind -> Maybe String)
-> [Maybe RepoKind] -> [Maybe String]
forall a b. (a -> b) -> [a] -> [b]
map ((RepoKind -> String) -> Maybe RepoKind -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RepoKind -> String
forall a. Show a => a -> String
show) ([Maybe RepoKind] -> [Maybe String])
-> (Flag (Maybe RepoKind) -> [Maybe RepoKind])
-> Flag (Maybe RepoKind)
-> [Maybe String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag (Maybe RepoKind) -> [Maybe RepoKind]
forall a. Flag a -> [a]
flagToList))

      , String
-> [String]
-> String
-> (GetFlags -> Flag TotalIndexState)
-> (Flag TotalIndexState -> GetFlags -> GetFlags)
-> MkOptDescr
     (GetFlags -> Flag TotalIndexState)
     (Flag TotalIndexState -> GetFlags -> GetFlags)
     GetFlags
-> OptionField GetFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"index-state"]
          (String
"Use source package index state as it existed at a previous time. " String -> String -> String
forall a. [a] -> [a] -> [a]
++
           String
"Accepts unix-timestamps (e.g. '@1474732068'), ISO8601 UTC timestamps " String -> String -> String
forall a. [a] -> [a] -> [a]
++
           String
"(e.g. '2016-09-24T17:47:48Z'), or 'HEAD' (default: 'HEAD'). " String -> String -> String
forall a. [a] -> [a] -> [a]
++
           String
"This determines which package versions are available as well as " String -> String -> String
forall a. [a] -> [a] -> [a]
++
           String
".cabal file revision is selected (unless --pristine is used).")
          GetFlags -> Flag TotalIndexState
getIndexState (\Flag TotalIndexState
v GetFlags
flags -> GetFlags
flags { getIndexState :: Flag TotalIndexState
getIndexState = Flag TotalIndexState
v })
          (String
-> ReadE (Flag TotalIndexState)
-> (Flag TotalIndexState -> [String])
-> MkOptDescr
     (GetFlags -> Flag TotalIndexState)
     (Flag TotalIndexState -> GetFlags -> GetFlags)
     GetFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"STATE" ((String -> String)
-> ParsecParser (Flag TotalIndexState)
-> ReadE (Flag TotalIndexState)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String -> String -> String
forall a b. a -> b -> a
const (String -> String -> String) -> String -> String -> String
forall a b. (a -> b) -> a -> b
$ String
"index-state must be a  " String -> String -> String
forall a. [a] -> [a] -> [a]
++
                                       String
"unix-timestamps (e.g. '@1474732068'), " String -> String -> String
forall a. [a] -> [a] -> [a]
++
                                       String
"a ISO8601 UTC timestamp " String -> String -> String
forall a. [a] -> [a] -> [a]
++
                                       String
"(e.g. '2016-09-24T17:47:48Z'), or 'HEAD'")
                                      (TotalIndexState -> Flag TotalIndexState
forall a. a -> Flag a
toFlag (TotalIndexState -> Flag TotalIndexState)
-> ParsecParser TotalIndexState
-> ParsecParser (Flag TotalIndexState)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser TotalIndexState
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec))
                          (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag TotalIndexState -> Flag String)
-> Flag TotalIndexState
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TotalIndexState -> String) -> Flag TotalIndexState -> Flag String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TotalIndexState -> String
forall a. Pretty a => a -> String
prettyShow))

       , String
-> [String]
-> String
-> (GetFlags -> Flag Bool)
-> (Flag Bool -> GetFlags -> GetFlags)
-> MkOptDescr
     (GetFlags -> Flag Bool)
     (Flag Bool -> GetFlags -> GetFlags)
     GetFlags
-> OptionField GetFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"pristine"]
           (String
"Unpack the original pristine tarball, rather than updating the "
           String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
".cabal file with the latest revision from the package archive.")
           GetFlags -> Flag Bool
getPristine (\Flag Bool
v GetFlags
flags -> GetFlags
flags { getPristine :: Flag Bool
getPristine = Flag Bool
v })
           MkOptDescr
  (GetFlags -> Flag Bool)
  (Flag Bool -> GetFlags -> GetFlags)
  GetFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
       ]
  }

-- | List of lines describing command @get@.
descriptionOfGetCommand :: [String]
descriptionOfGetCommand :: [String]
descriptionOfGetCommand =
  [ String
"Creates a local copy of a package's source code. By default it gets the source"
  , String
"tarball and unpacks it in a local subdirectory. Alternatively, with -s it will"
  , String
"get the code from the source repository specified by the package."
  ]

-- | Notes for the command @get@.
notesOfGetCommand
  :: String    -- ^ Either @"get"@ or @"unpack"@.
  -> String    -- ^ E.g. @"cabal"@.
  -> [String]  -- ^ List of lines.
notesOfGetCommand :: String -> String -> [String]
notesOfGetCommand String
cmd String
pname =
  [ String
"Examples:"
  , String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
unwords [ String
pname, String
cmd, String
"hlint" ]
  , String
"    Download the latest stable version of hlint;"
  , String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
unwords [ String
pname, String
cmd, String
"lens --source-repository=head" ]
  , String
"    Download the source repository of lens (i.e. git clone from github)."
  ]

-- 'cabal unpack' is a deprecated alias for 'cabal get'.
unpackCommand :: CommandUI GetFlags
unpackCommand :: CommandUI GetFlags
unpackCommand = CommandUI GetFlags
getCommand
  { commandName :: String
commandName        = String
"unpack"
  , commandSynopsis :: String
commandSynopsis    = String
synopsis
  , commandNotes :: Maybe (String -> String)
commandNotes       = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \ String
pname -> [String] -> String
unlines ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$
      String -> String -> [String]
notesOfGetCommand String
"unpack" String
pname
  , commandUsage :: String -> String
commandUsage       = String -> String -> String
usagePackages String
"unpack"
  }
  where
  synopsis :: String
synopsis = String
"Deprecated alias for 'get'."

instance Monoid GetFlags where
  mempty :: GetFlags
mempty = GetFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: GetFlags -> GetFlags -> GetFlags
mappend = GetFlags -> GetFlags -> GetFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup GetFlags where
  <> :: GetFlags -> GetFlags -> GetFlags
(<>) = GetFlags -> GetFlags -> GetFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * List flags
-- ------------------------------------------------------------

data ListFlags = ListFlags
    { ListFlags -> Flag Bool
listInstalled       :: Flag Bool
    , ListFlags -> Flag Bool
listSimpleOutput    :: Flag Bool
    , ListFlags -> Flag Bool
listCaseInsensitive :: Flag Bool
    , ListFlags -> Flag Verbosity
listVerbosity       :: Flag Verbosity
    , ListFlags -> [Maybe PackageDB]
listPackageDBs      :: [Maybe PackageDB]
    , ListFlags -> Flag String
listHcPath          :: Flag FilePath
    }
  deriving (forall x. ListFlags -> Rep ListFlags x)
-> (forall x. Rep ListFlags x -> ListFlags) -> Generic ListFlags
forall x. Rep ListFlags x -> ListFlags
forall x. ListFlags -> Rep ListFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFlags x -> ListFlags
$cfrom :: forall x. ListFlags -> Rep ListFlags x
Generic

defaultListFlags :: ListFlags
defaultListFlags :: ListFlags
defaultListFlags = ListFlags :: Flag Bool
-> Flag Bool
-> Flag Bool
-> Flag Verbosity
-> [Maybe PackageDB]
-> Flag String
-> ListFlags
ListFlags
    { listInstalled :: Flag Bool
listInstalled       = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False
    , listSimpleOutput :: Flag Bool
listSimpleOutput    = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False
    , listCaseInsensitive :: Flag Bool
listCaseInsensitive = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
True
    , listVerbosity :: Flag Verbosity
listVerbosity       = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal
    , listPackageDBs :: [Maybe PackageDB]
listPackageDBs      = []
    , listHcPath :: Flag String
listHcPath          = Flag String
forall a. Monoid a => a
mempty
    }

listCommand  :: CommandUI ListFlags
listCommand :: CommandUI ListFlags
listCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"list",
    commandSynopsis :: String
commandSynopsis     = String
"List packages matching a search string.",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"List all packages, or all packages matching one of the search"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" strings.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Use the package database specified with --package-db. "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If not specified, use the user package database.\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
         String
"Examples:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" list pandoc\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Will find pandoc, pandoc-citeproc, pandoc-lens, ...\n",
    commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"list" [ String
"[FLAGS]"
                                                   , String
"[FLAGS] STRINGS"],
    commandDefaultFlags :: ListFlags
commandDefaultFlags = ListFlags
defaultListFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField ListFlags]
commandOptions      = [OptionField ListFlags]
-> ShowOrParseArgs -> [OptionField ListFlags]
forall a b. a -> b -> a
const [OptionField ListFlags]
listOptions
  }

listOptions :: [OptionField ListFlags]
listOptions :: [OptionField ListFlags]
listOptions =
    [ (ListFlags -> Flag Verbosity)
-> (Flag Verbosity -> ListFlags -> ListFlags)
-> OptionField ListFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity ListFlags -> Flag Verbosity
listVerbosity (\Flag Verbosity
v ListFlags
flags -> ListFlags
flags { listVerbosity :: Flag Verbosity
listVerbosity = Flag Verbosity
v })

    , String
-> [String]
-> String
-> (ListFlags -> Flag Bool)
-> (Flag Bool -> ListFlags -> ListFlags)
-> MkOptDescr
     (ListFlags -> Flag Bool)
     (Flag Bool -> ListFlags -> ListFlags)
     ListFlags
-> OptionField ListFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"installed"]
        String
"Only print installed packages"
        ListFlags -> Flag Bool
listInstalled (\Flag Bool
v ListFlags
flags -> ListFlags
flags { listInstalled :: Flag Bool
listInstalled = Flag Bool
v })
        MkOptDescr
  (ListFlags -> Flag Bool)
  (Flag Bool -> ListFlags -> ListFlags)
  ListFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

    , String
-> [String]
-> String
-> (ListFlags -> Flag Bool)
-> (Flag Bool -> ListFlags -> ListFlags)
-> MkOptDescr
     (ListFlags -> Flag Bool)
     (Flag Bool -> ListFlags -> ListFlags)
     ListFlags
-> OptionField ListFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"simple-output"]
        String
"Print in a easy-to-parse format"
        ListFlags -> Flag Bool
listSimpleOutput (\Flag Bool
v ListFlags
flags -> ListFlags
flags { listSimpleOutput :: Flag Bool
listSimpleOutput = Flag Bool
v })
        MkOptDescr
  (ListFlags -> Flag Bool)
  (Flag Bool -> ListFlags -> ListFlags)
  ListFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
    , String
-> [String]
-> String
-> (ListFlags -> Flag Bool)
-> (Flag Bool -> ListFlags -> ListFlags)
-> MkOptDescr
     (ListFlags -> Flag Bool)
     (Flag Bool -> ListFlags -> ListFlags)
     ListFlags
-> OptionField ListFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [Char
'i'] [String
"ignore-case"]
        String
"Ignore case distinctions"
        ListFlags -> Flag Bool
listCaseInsensitive (\Flag Bool
v ListFlags
flags -> ListFlags
flags { listCaseInsensitive :: Flag Bool
listCaseInsensitive = Flag Bool
v })
        (OptFlags
-> OptFlags
-> MkOptDescr
     (ListFlags -> Flag Bool)
     (Flag Bool -> ListFlags -> ListFlags)
     ListFlags
forall a.
OptFlags
-> OptFlags -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt' ([Char
'i'], [String
"ignore-case"]) ([Char
'I'], [String
"strict-case"]))

    , String
-> [String]
-> String
-> (ListFlags -> [Maybe PackageDB])
-> ([Maybe PackageDB] -> ListFlags -> ListFlags)
-> MkOptDescr
     (ListFlags -> [Maybe PackageDB])
     ([Maybe PackageDB] -> ListFlags -> ListFlags)
     ListFlags
-> OptionField ListFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"package-db"]
      (   String
"Append the given package database to the list of package"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" databases used (to satisfy dependencies and register into)."
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" May be a specific file, 'global' or 'user'. The initial list"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is ['global'], ['global', 'user'],"
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" depending on context. Use 'clear' to reset the list to empty."
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" See the user guide for details.")
      ListFlags -> [Maybe PackageDB]
listPackageDBs (\[Maybe PackageDB]
v ListFlags
flags -> ListFlags
flags { listPackageDBs :: [Maybe PackageDB]
listPackageDBs = [Maybe PackageDB]
v })
      (String
-> (String -> [Maybe PackageDB])
-> ([Maybe PackageDB] -> [String])
-> MkOptDescr
     (ListFlags -> [Maybe PackageDB])
     ([Maybe PackageDB] -> ListFlags -> ListFlags)
     ListFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"DB" String -> [Maybe PackageDB]
readPackageDbList [Maybe PackageDB] -> [String]
showPackageDbList)

    , String
-> [String]
-> String
-> (ListFlags -> Flag String)
-> (Flag String -> ListFlags -> ListFlags)
-> MkOptDescr
     (ListFlags -> Flag String)
     (Flag String -> ListFlags -> ListFlags)
     ListFlags
-> OptionField ListFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"w" [String
"with-compiler"]
      String
"give the path to a particular compiler"
      ListFlags -> Flag String
listHcPath (\Flag String
v ListFlags
flags -> ListFlags
flags { listHcPath :: Flag String
listHcPath = Flag String
v })
      (String
-> MkOptDescr
     (ListFlags -> Flag String)
     (Flag String -> ListFlags -> ListFlags)
     ListFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"PATH")
    ]

listNeedsCompiler :: ListFlags -> Bool
listNeedsCompiler :: ListFlags -> Bool
listNeedsCompiler ListFlags
f =
    Bool -> (String -> Bool) -> Flag String -> Bool
forall b a. b -> (a -> b) -> Flag a -> b
flagElim Bool
False (Bool -> String -> Bool
forall a b. a -> b -> a
const Bool
True) (ListFlags -> Flag String
listHcPath ListFlags
f)
    Bool -> Bool -> Bool
|| Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
fromFlagOrDefault Bool
False (ListFlags -> Flag Bool
listInstalled ListFlags
f)

instance Monoid ListFlags where
  mempty :: ListFlags
mempty = ListFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: ListFlags -> ListFlags -> ListFlags
mappend = ListFlags -> ListFlags -> ListFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup ListFlags where
  <> :: ListFlags -> ListFlags -> ListFlags
(<>) = ListFlags -> ListFlags -> ListFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Info flags
-- ------------------------------------------------------------

data InfoFlags = InfoFlags {
    InfoFlags -> Flag Verbosity
infoVerbosity  :: Flag Verbosity,
    InfoFlags -> [Maybe PackageDB]
infoPackageDBs :: [Maybe PackageDB]
  } deriving (forall x. InfoFlags -> Rep InfoFlags x)
-> (forall x. Rep InfoFlags x -> InfoFlags) -> Generic InfoFlags
forall x. Rep InfoFlags x -> InfoFlags
forall x. InfoFlags -> Rep InfoFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InfoFlags x -> InfoFlags
$cfrom :: forall x. InfoFlags -> Rep InfoFlags x
Generic

defaultInfoFlags :: InfoFlags
defaultInfoFlags :: InfoFlags
defaultInfoFlags = InfoFlags :: Flag Verbosity -> [Maybe PackageDB] -> InfoFlags
InfoFlags {
    infoVerbosity :: Flag Verbosity
infoVerbosity  = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal,
    infoPackageDBs :: [Maybe PackageDB]
infoPackageDBs = []
  }

infoCommand  :: CommandUI InfoFlags
infoCommand :: CommandUI InfoFlags
infoCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
    commandName :: String
commandName         = String
"info",
    commandSynopsis :: String
commandSynopsis     = String
"Display detailed information about a particular package.",
    commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
      String
"Use the package database specified with --package-db. "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If not specified, use the user package database.\n",
    commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing,
    commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"info" [String
"[FLAGS] PACKAGES"],
    commandDefaultFlags :: InfoFlags
commandDefaultFlags = InfoFlags
defaultInfoFlags,
    commandOptions :: ShowOrParseArgs -> [OptionField InfoFlags]
commandOptions      = \ShowOrParseArgs
_ -> [
        (InfoFlags -> Flag Verbosity)
-> (Flag Verbosity -> InfoFlags -> InfoFlags)
-> OptionField InfoFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity InfoFlags -> Flag Verbosity
infoVerbosity (\Flag Verbosity
v InfoFlags
flags -> InfoFlags
flags { infoVerbosity :: Flag Verbosity
infoVerbosity = Flag Verbosity
v })

        , String
-> [String]
-> String
-> (InfoFlags -> [Maybe PackageDB])
-> ([Maybe PackageDB] -> InfoFlags -> InfoFlags)
-> MkOptDescr
     (InfoFlags -> [Maybe PackageDB])
     ([Maybe PackageDB] -> InfoFlags -> InfoFlags)
     InfoFlags
-> OptionField InfoFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"package-db"]
          (   String
"Append the given package database to the list of package"
           String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" databases used (to satisfy dependencies and register into)."
           String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" May be a specific file, 'global' or 'user'. The initial list"
           String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is ['global'], ['global', 'user'],"
           String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" depending on context. Use 'clear' to reset the list to empty."
           String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" See the user guide for details.")
          InfoFlags -> [Maybe PackageDB]
infoPackageDBs (\[Maybe PackageDB]
v InfoFlags
flags -> InfoFlags
flags { infoPackageDBs :: [Maybe PackageDB]
infoPackageDBs = [Maybe PackageDB]
v })
          (String
-> (String -> [Maybe PackageDB])
-> ([Maybe PackageDB] -> [String])
-> MkOptDescr
     (InfoFlags -> [Maybe PackageDB])
     ([Maybe PackageDB] -> InfoFlags -> InfoFlags)
     InfoFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"DB" String -> [Maybe PackageDB]
readPackageDbList [Maybe PackageDB] -> [String]
showPackageDbList)

        ]
  }

instance Monoid InfoFlags where
  mempty :: InfoFlags
mempty = InfoFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: InfoFlags -> InfoFlags -> InfoFlags
mappend = InfoFlags -> InfoFlags -> InfoFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup InfoFlags where
  <> :: InfoFlags -> InfoFlags -> InfoFlags
(<>) = InfoFlags -> InfoFlags -> InfoFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Install flags
-- ------------------------------------------------------------

-- | Install takes the same flags as configure along with a few extras.
--
data InstallFlags = InstallFlags {
    InstallFlags -> Flag Bool
installDocumentation    :: Flag Bool,
    InstallFlags -> Flag PathTemplate
installHaddockIndex     :: Flag PathTemplate,
    InstallFlags -> Flag CopyDest
installDest             :: Flag Cabal.CopyDest,
    InstallFlags -> Flag Bool
installDryRun           :: Flag Bool,
    InstallFlags -> Flag Bool
installOnlyDownload     :: Flag Bool,
    InstallFlags -> Flag Int
installMaxBackjumps     :: Flag Int,
    InstallFlags -> Flag ReorderGoals
installReorderGoals     :: Flag ReorderGoals,
    InstallFlags -> Flag CountConflicts
installCountConflicts   :: Flag CountConflicts,
    InstallFlags -> Flag FineGrainedConflicts
installFineGrainedConflicts :: Flag FineGrainedConflicts,
    InstallFlags -> Flag MinimizeConflictSet
installMinimizeConflictSet :: Flag MinimizeConflictSet,
    InstallFlags -> Flag IndependentGoals
installIndependentGoals :: Flag IndependentGoals,
    InstallFlags -> Flag ShadowPkgs
installShadowPkgs       :: Flag ShadowPkgs,
    InstallFlags -> Flag StrongFlags
installStrongFlags      :: Flag StrongFlags,
    InstallFlags -> Flag AllowBootLibInstalls
installAllowBootLibInstalls :: Flag AllowBootLibInstalls,
    InstallFlags -> Flag OnlyConstrained
installOnlyConstrained  :: Flag OnlyConstrained,
    InstallFlags -> Flag Bool
installReinstall        :: Flag Bool,
    InstallFlags -> Flag AvoidReinstalls
installAvoidReinstalls  :: Flag AvoidReinstalls,
    InstallFlags -> Flag Bool
installOverrideReinstall :: Flag Bool,
    InstallFlags -> Flag Bool
installUpgradeDeps      :: Flag Bool,
    InstallFlags -> Flag Bool
installOnly             :: Flag Bool,
    InstallFlags -> Flag Bool
installOnlyDeps         :: Flag Bool,
    InstallFlags -> Flag TotalIndexState
installIndexState       :: Flag TotalIndexState,
    InstallFlags -> Flag String
installRootCmd          :: Flag String,
    InstallFlags -> NubList PathTemplate
installSummaryFile      :: NubList PathTemplate,
    InstallFlags -> Flag PathTemplate
installLogFile          :: Flag PathTemplate,
    InstallFlags -> Flag ReportLevel
installBuildReports     :: Flag ReportLevel,
    InstallFlags -> Flag Bool
installReportPlanningFailure :: Flag Bool,
    -- Note: symlink-bindir is no longer used by v2-install and can be removed
    -- when removing v1 commands
    InstallFlags -> Flag String
installSymlinkBinDir    :: Flag FilePath,
    InstallFlags -> Flag Bool
installPerComponent     :: Flag Bool,
    InstallFlags -> Flag (Maybe Int)
installNumJobs          :: Flag (Maybe Int),
    InstallFlags -> Flag Bool
installKeepGoing        :: Flag Bool,
    InstallFlags -> Flag Bool
installRunTests         :: Flag Bool,
    InstallFlags -> Flag Bool
installOfflineMode      :: Flag Bool
  }
  deriving (InstallFlags -> InstallFlags -> Bool
(InstallFlags -> InstallFlags -> Bool)
-> (InstallFlags -> InstallFlags -> Bool) -> Eq InstallFlags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstallFlags -> InstallFlags -> Bool
$c/= :: InstallFlags -> InstallFlags -> Bool
== :: InstallFlags -> InstallFlags -> Bool
$c== :: InstallFlags -> InstallFlags -> Bool
Eq, Int -> InstallFlags -> String -> String
[InstallFlags] -> String -> String
InstallFlags -> String
(Int -> InstallFlags -> String -> String)
-> (InstallFlags -> String)
-> ([InstallFlags] -> String -> String)
-> Show InstallFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [InstallFlags] -> String -> String
$cshowList :: [InstallFlags] -> String -> String
show :: InstallFlags -> String
$cshow :: InstallFlags -> String
showsPrec :: Int -> InstallFlags -> String -> String
$cshowsPrec :: Int -> InstallFlags -> String -> String
Show, (forall x. InstallFlags -> Rep InstallFlags x)
-> (forall x. Rep InstallFlags x -> InstallFlags)
-> Generic InstallFlags
forall x. Rep InstallFlags x -> InstallFlags
forall x. InstallFlags -> Rep InstallFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstallFlags x -> InstallFlags
$cfrom :: forall x. InstallFlags -> Rep InstallFlags x
Generic)

instance Binary InstallFlags

defaultInstallFlags :: InstallFlags
defaultInstallFlags :: InstallFlags
defaultInstallFlags = InstallFlags :: Flag Bool
-> Flag PathTemplate
-> Flag CopyDest
-> Flag Bool
-> Flag Bool
-> Flag Int
-> Flag ReorderGoals
-> Flag CountConflicts
-> Flag FineGrainedConflicts
-> Flag MinimizeConflictSet
-> Flag IndependentGoals
-> Flag ShadowPkgs
-> Flag StrongFlags
-> Flag AllowBootLibInstalls
-> Flag OnlyConstrained
-> Flag Bool
-> Flag AvoidReinstalls
-> Flag Bool
-> Flag Bool
-> Flag Bool
-> Flag Bool
-> Flag TotalIndexState
-> Flag String
-> NubList PathTemplate
-> Flag PathTemplate
-> Flag ReportLevel
-> Flag Bool
-> Flag String
-> Flag Bool
-> Flag (Maybe Int)
-> Flag Bool
-> Flag Bool
-> Flag Bool
-> InstallFlags
InstallFlags {
    installDocumentation :: Flag Bool
installDocumentation   = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installHaddockIndex :: Flag PathTemplate
installHaddockIndex    = PathTemplate -> Flag PathTemplate
forall a. a -> Flag a
Flag PathTemplate
docIndexFile,
    installDest :: Flag CopyDest
installDest            = CopyDest -> Flag CopyDest
forall a. a -> Flag a
Flag CopyDest
Cabal.NoCopyDest,
    installDryRun :: Flag Bool
installDryRun          = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installOnlyDownload :: Flag Bool
installOnlyDownload    = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installMaxBackjumps :: Flag Int
installMaxBackjumps    = Int -> Flag Int
forall a. a -> Flag a
Flag Int
defaultMaxBackjumps,
    installReorderGoals :: Flag ReorderGoals
installReorderGoals    = ReorderGoals -> Flag ReorderGoals
forall a. a -> Flag a
Flag (Bool -> ReorderGoals
ReorderGoals Bool
False),
    installCountConflicts :: Flag CountConflicts
installCountConflicts  = CountConflicts -> Flag CountConflicts
forall a. a -> Flag a
Flag (Bool -> CountConflicts
CountConflicts Bool
True),
    installFineGrainedConflicts :: Flag FineGrainedConflicts
installFineGrainedConflicts = FineGrainedConflicts -> Flag FineGrainedConflicts
forall a. a -> Flag a
Flag (Bool -> FineGrainedConflicts
FineGrainedConflicts Bool
True),
    installMinimizeConflictSet :: Flag MinimizeConflictSet
installMinimizeConflictSet = MinimizeConflictSet -> Flag MinimizeConflictSet
forall a. a -> Flag a
Flag (Bool -> MinimizeConflictSet
MinimizeConflictSet Bool
False),
    installIndependentGoals :: Flag IndependentGoals
installIndependentGoals= IndependentGoals -> Flag IndependentGoals
forall a. a -> Flag a
Flag (Bool -> IndependentGoals
IndependentGoals Bool
False),
    installShadowPkgs :: Flag ShadowPkgs
installShadowPkgs      = ShadowPkgs -> Flag ShadowPkgs
forall a. a -> Flag a
Flag (Bool -> ShadowPkgs
ShadowPkgs Bool
False),
    installStrongFlags :: Flag StrongFlags
installStrongFlags     = StrongFlags -> Flag StrongFlags
forall a. a -> Flag a
Flag (Bool -> StrongFlags
StrongFlags Bool
False),
    installAllowBootLibInstalls :: Flag AllowBootLibInstalls
installAllowBootLibInstalls = AllowBootLibInstalls -> Flag AllowBootLibInstalls
forall a. a -> Flag a
Flag (Bool -> AllowBootLibInstalls
AllowBootLibInstalls Bool
False),
    installOnlyConstrained :: Flag OnlyConstrained
installOnlyConstrained = OnlyConstrained -> Flag OnlyConstrained
forall a. a -> Flag a
Flag OnlyConstrained
OnlyConstrainedNone,
    installReinstall :: Flag Bool
installReinstall       = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installAvoidReinstalls :: Flag AvoidReinstalls
installAvoidReinstalls = AvoidReinstalls -> Flag AvoidReinstalls
forall a. a -> Flag a
Flag (Bool -> AvoidReinstalls
AvoidReinstalls Bool
False),
    installOverrideReinstall :: Flag Bool
installOverrideReinstall = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installUpgradeDeps :: Flag Bool
installUpgradeDeps     = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installOnly :: Flag Bool
installOnly            = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installOnlyDeps :: Flag Bool
installOnlyDeps        = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installIndexState :: Flag TotalIndexState
installIndexState      = Flag TotalIndexState
forall a. Monoid a => a
mempty,
    installRootCmd :: Flag String
installRootCmd         = Flag String
forall a. Monoid a => a
mempty,
    installSummaryFile :: NubList PathTemplate
installSummaryFile     = NubList PathTemplate
forall a. Monoid a => a
mempty,
    installLogFile :: Flag PathTemplate
installLogFile         = Flag PathTemplate
forall a. Monoid a => a
mempty,
    installBuildReports :: Flag ReportLevel
installBuildReports    = ReportLevel -> Flag ReportLevel
forall a. a -> Flag a
Flag ReportLevel
NoReports,
    installReportPlanningFailure :: Flag Bool
installReportPlanningFailure = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installSymlinkBinDir :: Flag String
installSymlinkBinDir   = Flag String
forall a. Monoid a => a
mempty,
    installPerComponent :: Flag Bool
installPerComponent    = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
True,
    installNumJobs :: Flag (Maybe Int)
installNumJobs         = Flag (Maybe Int)
forall a. Monoid a => a
mempty,
    installKeepGoing :: Flag Bool
installKeepGoing       = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installRunTests :: Flag Bool
installRunTests        = Flag Bool
forall a. Monoid a => a
mempty,
    installOfflineMode :: Flag Bool
installOfflineMode     = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False
  }
  where
    docIndexFile :: PathTemplate
docIndexFile = String -> PathTemplate
toPathTemplate (String
"$datadir" String -> String -> String
</> String
"doc"
                                   String -> String -> String
</> String
"$arch-$os-$compiler" String -> String -> String
</> String
"index.html")

defaultMaxBackjumps :: Int
defaultMaxBackjumps :: Int
defaultMaxBackjumps = Int
4000

defaultSolver :: PreSolver
defaultSolver :: PreSolver
defaultSolver = PreSolver
AlwaysModular

allSolvers :: String
allSolvers :: String
allSolvers = String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " ((PreSolver -> String) -> [PreSolver] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map PreSolver -> String
forall a. Pretty a => a -> String
prettyShow ([PreSolver
forall a. Bounded a => a
minBound .. PreSolver
forall a. Bounded a => a
maxBound] :: [PreSolver]))

installCommand :: CommandUI ( ConfigFlags, ConfigExFlags, InstallFlags
                            , HaddockFlags, TestFlags, BenchmarkFlags
                            )
installCommand :: CommandUI
  (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
   BenchmarkFlags)
installCommand = CommandUI :: forall flags.
String
-> String
-> (String -> String)
-> Maybe (String -> String)
-> Maybe (String -> String)
-> flags
-> (ShowOrParseArgs -> [OptionField flags])
-> CommandUI flags
CommandUI {
  commandName :: String
commandName         = String
"install",
  commandSynopsis :: String
commandSynopsis     = String
"Install packages.",
  commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"v1-install" [ String
"[FLAGS]"
                                                    , String
"[FLAGS] PACKAGES"
                                                    ],
  commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
        String
"Installs one or more packages. By default, the installed package"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" will be registered in the user's package database."
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If PACKAGES are specified, downloads and installs those packages."
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" Otherwise, install the package in the current directory (and/or its"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" dependencies) (there must be exactly one .cabal file in the current"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" directory).\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"The flags to `v1-install` are saved and"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" affect future commands such as `v1-build` and `v1-repl`. See the help for"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" `v1-configure` for a list of commands being affected.\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Installed executables will by default"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" be put into `~/.cabal/bin/`."
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" If you want installed executable to be available globally, make"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" sure that the PATH environment variable contains that directory.\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n",
  commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
        ( case CommandUI ConfigFlags -> Maybe (String -> String)
forall flags. CommandUI flags -> Maybe (String -> String)
commandNotes
               (CommandUI ConfigFlags -> Maybe (String -> String))
-> CommandUI ConfigFlags -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ ProgramDb -> CommandUI ConfigFlags
Cabal.configureCommand ProgramDb
defaultProgramDb
          of Just String -> String
desc -> String -> String
desc String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
             Maybe (String -> String)
Nothing   -> String
""
        )
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Examples:\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-install                 "
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Package in the current directory\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-install foo             "
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Package from the hackage server\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-install foo-1.0         "
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Specific version of a package\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-install 'foo < 2'       "
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Constrained package version\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" v1-install haddock --bindir=$HOME/hask-bin/ --datadir=$HOME/hask-data/\n"
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ((Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map (Char -> Char -> Char
forall a b. a -> b -> a
const Char
' ') String
pname)
                      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"                         "
     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    Change installation destination\n",
  commandDefaultFlags :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
 BenchmarkFlags)
commandDefaultFlags = (ConfigFlags
forall a. Monoid a => a
mempty, ConfigExFlags
forall a. Monoid a => a
mempty, InstallFlags
forall a. Monoid a => a
mempty, HaddockFlags
forall a. Monoid a => a
mempty, TestFlags
forall a. Monoid a => a
mempty, BenchmarkFlags
forall a. Monoid a => a
mempty),
  commandOptions :: ShowOrParseArgs
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
       ((ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
  TestFlags, BenchmarkFlags)
 -> ConfigFlags)
-> (ConfigFlags
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags)
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags))
-> [OptionField ConfigFlags]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
 BenchmarkFlags)
-> ConfigFlags
forall a b c d e f. (a, b, c, d, e, f) -> a
get1 ConfigFlags
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
forall a a b c d e f. a -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set1
       -- Note: [Hidden Flags]
       -- hide "constraint", "dependency", and
       -- "exact-configuration" from the configure options.
       ((OptionField ConfigFlags -> Bool)
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String
"constraint", String
"dependency"
                           , String
"exact-configuration"])
                (String -> Bool)
-> (OptionField ConfigFlags -> String)
-> OptionField ConfigFlags
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OptionField ConfigFlags -> String
forall a. OptionField a -> String
optionName) ([OptionField ConfigFlags] -> [OptionField ConfigFlags])
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a b. (a -> b) -> a -> b
$
                              ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions   ShowOrParseArgs
showOrParseArgs)
    [OptionField
   (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
    BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall a. [a] -> [a] -> [a]
++ ((ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
  TestFlags, BenchmarkFlags)
 -> ConfigExFlags)
-> (ConfigExFlags
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags)
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags))
-> [OptionField ConfigExFlags]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
 BenchmarkFlags)
-> ConfigExFlags
forall a b c d e f. (a, b, c, d, e, f) -> b
get2 ConfigExFlags
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
forall b a b c d e f. b -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set2 (ShowOrParseArgs -> ConstraintSource -> [OptionField ConfigExFlags]
configureExOptions ShowOrParseArgs
showOrParseArgs ConstraintSource
ConstraintSourceCommandlineFlag)
    [OptionField
   (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
    BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall a. [a] -> [a] -> [a]
++ ((ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
  TestFlags, BenchmarkFlags)
 -> InstallFlags)
-> (InstallFlags
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags)
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags))
-> [OptionField InstallFlags]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
 BenchmarkFlags)
-> InstallFlags
forall a b c d e f. (a, b, c, d, e, f) -> c
get3 InstallFlags
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
forall c a b c d e f. c -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set3
       -- hide "target-package-db" flag from the
       -- install options.
       ((OptionField InstallFlags -> Bool)
-> [OptionField InstallFlags] -> [OptionField InstallFlags]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String
"target-package-db"])
                (String -> Bool)
-> (OptionField InstallFlags -> String)
-> OptionField InstallFlags
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OptionField InstallFlags -> String
forall a. OptionField a -> String
optionName) ([OptionField InstallFlags] -> [OptionField InstallFlags])
-> [OptionField InstallFlags] -> [OptionField InstallFlags]
forall a b. (a -> b) -> a -> b
$
                              ShowOrParseArgs -> [OptionField InstallFlags]
installOptions     ShowOrParseArgs
showOrParseArgs)
    [OptionField
   (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
    BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall a. [a] -> [a] -> [a]
++ ((ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
  TestFlags, BenchmarkFlags)
 -> HaddockFlags)
-> (HaddockFlags
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags)
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags))
-> [OptionField HaddockFlags]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
 BenchmarkFlags)
-> HaddockFlags
forall a b c d e f. (a, b, c, d, e, f) -> d
get4 HaddockFlags
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
forall d a b c d e f. d -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set4 (ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions     ShowOrParseArgs
showOrParseArgs)
    [OptionField
   (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
    BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall a. [a] -> [a] -> [a]
++ ((ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
  TestFlags, BenchmarkFlags)
 -> TestFlags)
-> (TestFlags
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags)
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags))
-> [OptionField TestFlags]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
 BenchmarkFlags)
-> TestFlags
forall a b c d e f. (a, b, c, d, e, f) -> e
get5 TestFlags
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
forall e a b c d e f. e -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set5 (ShowOrParseArgs -> [OptionField TestFlags]
testOptions        ShowOrParseArgs
showOrParseArgs)
    [OptionField
   (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
    BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall a. [a] -> [a] -> [a]
++ ((ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
  TestFlags, BenchmarkFlags)
 -> BenchmarkFlags)
-> (BenchmarkFlags
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags)
    -> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
        TestFlags, BenchmarkFlags))
-> [OptionField BenchmarkFlags]
-> [OptionField
      (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
       BenchmarkFlags)]
forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
 BenchmarkFlags)
-> BenchmarkFlags
forall a b c d e f. (a, b, c, d, e, f) -> f
get6 BenchmarkFlags
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
-> (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
    TestFlags, BenchmarkFlags)
forall f a b c d e f. f -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set6 (ShowOrParseArgs -> [OptionField BenchmarkFlags]
benchmarkOptions   ShowOrParseArgs
showOrParseArgs)
  }
  where
    get1 :: (a, b, c, d, e, f) -> a
get1 (a
a,b
_,c
_,d
_,e
_,f
_) = a
a; set1 :: a -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set1 a
a (a
_,b
b,c
c,d
d,e
e,f
f) = (a
a,b
b,c
c,d
d,e
e,f
f)
    get2 :: (a, b, c, d, e, f) -> b
get2 (a
_,b
b,c
_,d
_,e
_,f
_) = b
b; set2 :: b -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set2 b
b (a
a,b
_,c
c,d
d,e
e,f
f) = (a
a,b
b,c
c,d
d,e
e,f
f)
    get3 :: (a, b, c, d, e, f) -> c
get3 (a
_,b
_,c
c,d
_,e
_,f
_) = c
c; set3 :: c -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set3 c
c (a
a,b
b,c
_,d
d,e
e,f
f) = (a
a,b
b,c
c,d
d,e
e,f
f)
    get4 :: (a, b, c, d, e, f) -> d
get4 (a
_,b
_,c
_,d
d,e
_,f
_) = d
d; set4 :: d -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set4 d
d (a
a,b
b,c
c,d
_,e
e,f
f) = (a
a,b
b,c
c,d
d,e
e,f
f)
    get5 :: (a, b, c, d, e, f) -> e
get5 (a
_,b
_,c
_,d
_,e
e,f
_) = e
e; set5 :: e -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set5 e
e (a
a,b
b,c
c,d
d,e
_,f
f) = (a
a,b
b,c
c,d
d,e
e,f
f)
    get6 :: (a, b, c, d, e, f) -> f
get6 (a
_,b
_,c
_,d
_,e
_,f
f) = f
f; set6 :: f -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
set6 f
f (a
a,b
b,c
c,d
d,e
e,f
_) = (a
a,b
b,c
c,d
d,e
e,f
f)

haddockCommand :: CommandUI HaddockFlags
haddockCommand :: CommandUI HaddockFlags
haddockCommand = CommandUI HaddockFlags
Cabal.haddockCommand
  { commandUsage :: String -> String
commandUsage = String -> [String] -> String -> String
usageAlternatives String
"v1-haddock" ([String] -> String -> String) -> [String] -> String -> String
forall a b. (a -> b) -> a -> b
$
      [ String
"[FLAGS]", String
"COMPONENTS [FLAGS]" ]
  }

filterHaddockArgs :: [String] -> Version -> [String]
filterHaddockArgs :: [String] -> Version -> [String]
filterHaddockArgs [String]
args Version
cabalLibVersion
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int] -> Version
mkVersion [Int
2,Int
3,Int
0] = [String]
args_latest
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
2,Int
3,Int
0] = [String]
forall a. [a]
args_2_3_0
  | Bool
otherwise = [String]
args_latest
  where
    args_latest :: [String]
args_latest = [String]
args

    -- Cabal < 2.3 doesn't know about per-component haddock
    args_2_3_0 :: [a]
args_2_3_0 = []

filterHaddockFlags :: HaddockFlags -> Version -> HaddockFlags
filterHaddockFlags :: HaddockFlags -> Version -> HaddockFlags
filterHaddockFlags HaddockFlags
flags Version
cabalLibVersion
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int] -> Version
mkVersion [Int
2,Int
3,Int
0] = HaddockFlags
flags_latest
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
2,Int
3,Int
0] = HaddockFlags
flags_2_3_0
  | Bool
otherwise = HaddockFlags
flags_latest
  where
    flags_latest :: HaddockFlags
flags_latest = HaddockFlags
flags

    flags_2_3_0 :: HaddockFlags
flags_2_3_0 = HaddockFlags
flags_latest {
      -- Cabal < 2.3 doesn't know about per-component haddock
      haddockArgs :: [String]
haddockArgs = []
      }

haddockOptions :: ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions :: ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions ShowOrParseArgs
showOrParseArgs
  = [ OptionField HaddockFlags
opt { optionName :: String
optionName = String
"haddock-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name,
            optionDescr :: [OptDescr HaddockFlags]
optionDescr = [ (OptFlags -> OptFlags)
-> OptDescr HaddockFlags -> OptDescr HaddockFlags
forall a. (OptFlags -> OptFlags) -> OptDescr a -> OptDescr a
fmapOptFlags (\(String
_, [String]
lflags) -> ([], (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
"haddock-" String -> String -> String
forall a. [a] -> [a] -> [a]
++) [String]
lflags)) OptDescr HaddockFlags
descr
                          | OptDescr HaddockFlags
descr <- OptionField HaddockFlags -> [OptDescr HaddockFlags]
forall a. OptionField a -> [OptDescr a]
optionDescr OptionField HaddockFlags
opt] }
    | OptionField HaddockFlags
opt <- CommandUI HaddockFlags
-> ShowOrParseArgs -> [OptionField HaddockFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI HaddockFlags
Cabal.haddockCommand ShowOrParseArgs
showOrParseArgs
    , let name :: String
name = OptionField HaddockFlags -> String
forall a. OptionField a -> String
optionName OptionField HaddockFlags
opt
    , String
name String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String
"hoogle", String
"html", String
"html-location"
                  ,String
"executables", String
"tests", String
"benchmarks", String
"all", String
"internal", String
"css"
                  ,String
"hyperlink-source", String
"quickjump", String
"hscolour-css"
                  ,String
"contents-location", String
"for-hackage"]
    ]

testOptions :: ShowOrParseArgs -> [OptionField TestFlags]
testOptions :: ShowOrParseArgs -> [OptionField TestFlags]
testOptions ShowOrParseArgs
showOrParseArgs
  = [ OptionField TestFlags
opt { optionName :: String
optionName = String -> String
prefixTest String
name,
            optionDescr :: [OptDescr TestFlags]
optionDescr = [ (OptFlags -> OptFlags) -> OptDescr TestFlags -> OptDescr TestFlags
forall a. (OptFlags -> OptFlags) -> OptDescr a -> OptDescr a
fmapOptFlags (\(String
_, [String]
lflags) -> ([], (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map String -> String
prefixTest [String]
lflags)) OptDescr TestFlags
descr
                          | OptDescr TestFlags
descr <- OptionField TestFlags -> [OptDescr TestFlags]
forall a. OptionField a -> [OptDescr a]
optionDescr OptionField TestFlags
opt] }
    | OptionField TestFlags
opt <- CommandUI TestFlags -> ShowOrParseArgs -> [OptionField TestFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI TestFlags
Cabal.testCommand ShowOrParseArgs
showOrParseArgs
    , let name :: String
name = OptionField TestFlags -> String
forall a. OptionField a -> String
optionName OptionField TestFlags
opt
    , String
name String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String
"log", String
"machine-log", String
"show-details", String
"keep-tix-files"
                  ,String
"fail-when-no-test-suites", String
"test-options", String
"test-option"
                  ,String
"test-wrapper"]
    ]
  where
    prefixTest :: String -> String
prefixTest String
name | String
"test-" String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` String
name = String
name
                    | Bool
otherwise = String
"test-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name

benchmarkOptions :: ShowOrParseArgs -> [OptionField BenchmarkFlags]
benchmarkOptions :: ShowOrParseArgs -> [OptionField BenchmarkFlags]
benchmarkOptions ShowOrParseArgs
showOrParseArgs
  = [ OptionField BenchmarkFlags
opt { optionName :: String
optionName = String -> String
prefixBenchmark String
name,
            optionDescr :: [OptDescr BenchmarkFlags]
optionDescr = [ (OptFlags -> OptFlags)
-> OptDescr BenchmarkFlags -> OptDescr BenchmarkFlags
forall a. (OptFlags -> OptFlags) -> OptDescr a -> OptDescr a
fmapOptFlags (\(String
_, [String]
lflags) -> ([], (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map String -> String
prefixBenchmark [String]
lflags)) OptDescr BenchmarkFlags
descr
                          | OptDescr BenchmarkFlags
descr <- OptionField BenchmarkFlags -> [OptDescr BenchmarkFlags]
forall a. OptionField a -> [OptDescr a]
optionDescr OptionField BenchmarkFlags
opt] }
    | OptionField BenchmarkFlags
opt <- CommandUI BenchmarkFlags
-> ShowOrParseArgs -> [OptionField BenchmarkFlags]
forall flags.
CommandUI flags -> ShowOrParseArgs -> [OptionField flags]
commandOptions CommandUI BenchmarkFlags
Cabal.benchmarkCommand ShowOrParseArgs
showOrParseArgs
    , let name :: String
name = OptionField BenchmarkFlags -> String
forall a. OptionField a -> String
optionName OptionField BenchmarkFlags
opt
    , String
name String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String
"benchmark-options", String
"benchmark-option"]
    ]
  where
    prefixBenchmark :: String -> String
prefixBenchmark String
name | String
"benchmark-" String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` String
name = String
name
                         | Bool
otherwise = String
"benchmark-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name

fmapOptFlags :: (OptFlags -> OptFlags) -> OptDescr a -> OptDescr a
fmapOptFlags :: (OptFlags -> OptFlags) -> OptDescr a -> OptDescr a
fmapOptFlags OptFlags -> OptFlags
modify (ReqArg String
d OptFlags
f String
p ReadE (a -> a)
r a -> [String]
w)    = String
-> OptFlags
-> String
-> ReadE (a -> a)
-> (a -> [String])
-> OptDescr a
forall a.
String
-> OptFlags
-> String
-> ReadE (a -> a)
-> (a -> [String])
-> OptDescr a
ReqArg String
d (OptFlags -> OptFlags
modify OptFlags
f) String
p ReadE (a -> a)
r a -> [String]
w
fmapOptFlags OptFlags -> OptFlags
modify (OptArg String
d OptFlags
f String
p ReadE (a -> a)
r a -> a
i a -> [Maybe String]
w)  = String
-> OptFlags
-> String
-> ReadE (a -> a)
-> (a -> a)
-> (a -> [Maybe String])
-> OptDescr a
forall a.
String
-> OptFlags
-> String
-> ReadE (a -> a)
-> (a -> a)
-> (a -> [Maybe String])
-> OptDescr a
OptArg String
d (OptFlags -> OptFlags
modify OptFlags
f) String
p ReadE (a -> a)
r a -> a
i a -> [Maybe String]
w
fmapOptFlags OptFlags -> OptFlags
modify (ChoiceOpt [(String, OptFlags, a -> a, a -> Bool)]
xs)        = [(String, OptFlags, a -> a, a -> Bool)] -> OptDescr a
forall a. [(String, OptFlags, a -> a, a -> Bool)] -> OptDescr a
ChoiceOpt [(String
d, OptFlags -> OptFlags
modify OptFlags
f, a -> a
i, a -> Bool
w) | (String
d, OptFlags
f, a -> a
i, a -> Bool
w) <- [(String, OptFlags, a -> a, a -> Bool)]
xs]
fmapOptFlags OptFlags -> OptFlags
modify (BoolOpt String
d OptFlags
f1 OptFlags
f2 Bool -> a -> a
r a -> Maybe Bool
w) = String
-> OptFlags
-> OptFlags
-> (Bool -> a -> a)
-> (a -> Maybe Bool)
-> OptDescr a
forall a.
String
-> OptFlags
-> OptFlags
-> (Bool -> a -> a)
-> (a -> Maybe Bool)
-> OptDescr a
BoolOpt String
d (OptFlags -> OptFlags
modify OptFlags
f1) (OptFlags -> OptFlags
modify OptFlags
f2) Bool -> a -> a
r a -> Maybe Bool
w

installOptions ::  ShowOrParseArgs -> [OptionField InstallFlags]
installOptions :: ShowOrParseArgs -> [OptionField InstallFlags]
installOptions ShowOrParseArgs
showOrParseArgs =
      [ String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"documentation"]
          String
"building of documentation"
          InstallFlags -> Flag Bool
installDocumentation (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installDocumentation :: Flag Bool
installDocumentation = Flag Bool
v })
          (String
-> String
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      , String
-> [String]
-> String
-> (InstallFlags -> Flag PathTemplate)
-> (Flag PathTemplate -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag PathTemplate)
     (Flag PathTemplate -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"doc-index-file"]
          String
"A central index of haddock API documentation (template cannot use $pkgid)"
          InstallFlags -> Flag PathTemplate
installHaddockIndex (\Flag PathTemplate
v InstallFlags
flags -> InstallFlags
flags { installHaddockIndex :: Flag PathTemplate
installHaddockIndex = Flag PathTemplate
v })
          (String
-> (String -> Flag PathTemplate)
-> (Flag PathTemplate -> [String])
-> MkOptDescr
     (InstallFlags -> Flag PathTemplate)
     (Flag PathTemplate -> InstallFlags -> InstallFlags)
     InstallFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"TEMPLATE" (PathTemplate -> Flag PathTemplate
forall a. a -> Flag a
toFlag(PathTemplate -> Flag PathTemplate)
-> (String -> PathTemplate) -> String -> Flag PathTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
.String -> PathTemplate
toPathTemplate)
                              (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag PathTemplate -> Flag String)
-> Flag PathTemplate
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PathTemplate -> String) -> Flag PathTemplate -> Flag String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PathTemplate -> String
fromPathTemplate))

      , String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"dry-run"]
          String
"Do not install anything, only print what would be installed."
          InstallFlags -> Flag Bool
installDryRun (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installDryRun :: Flag Bool
installDryRun = Flag Bool
v })
          MkOptDescr
  (InstallFlags -> Flag Bool)
  (Flag Bool -> InstallFlags -> InstallFlags)
  InstallFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      , String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"only-download"]
          String
"Do not build anything, only fetch the packages."
          InstallFlags -> Flag Bool
installOnlyDownload (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installOnlyDownload :: Flag Bool
installOnlyDownload = Flag Bool
v })
          MkOptDescr
  (InstallFlags -> Flag Bool)
  (Flag Bool -> InstallFlags -> InstallFlags)
  InstallFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      , String
-> [String]
-> String
-> (InstallFlags -> Flag CopyDest)
-> (Flag CopyDest -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag CopyDest)
     (Flag CopyDest -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"target-package-db"]
         String
"package database to install into. Required when using ${pkgroot} prefix."
         InstallFlags -> Flag CopyDest
installDest (\Flag CopyDest
v InstallFlags
flags -> InstallFlags
flags { installDest :: Flag CopyDest
installDest = Flag CopyDest
v })
         (String
-> ReadE (Flag CopyDest)
-> (Flag CopyDest -> [String])
-> MkOptDescr
     (InstallFlags -> Flag CopyDest)
     (Flag CopyDest -> InstallFlags -> InstallFlags)
     InstallFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"DATABASE" ((String -> Flag CopyDest) -> ReadE (Flag CopyDest)
forall a. (String -> a) -> ReadE a
succeedReadE (CopyDest -> Flag CopyDest
forall a. a -> Flag a
Flag (CopyDest -> Flag CopyDest)
-> (String -> CopyDest) -> String -> Flag CopyDest
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CopyDest
Cabal.CopyToDb))
                            (\Flag CopyDest
f -> case Flag CopyDest
f of Flag (Cabal.CopyToDb String
p) -> [String
p]; Flag CopyDest
_ -> []))
      ] [OptionField InstallFlags]
-> [OptionField InstallFlags] -> [OptionField InstallFlags]
forall a. [a] -> [a] -> [a]
++

      ShowOrParseArgs
-> (InstallFlags -> Flag Int)
-> (Flag Int -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag ReorderGoals)
-> (Flag ReorderGoals -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag CountConflicts)
-> (Flag CountConflicts -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag FineGrainedConflicts)
-> (Flag FineGrainedConflicts -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag MinimizeConflictSet)
-> (Flag MinimizeConflictSet -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag IndependentGoals)
-> (Flag IndependentGoals -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag ShadowPkgs)
-> (Flag ShadowPkgs -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag StrongFlags)
-> (Flag StrongFlags -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag AllowBootLibInstalls)
-> (Flag AllowBootLibInstalls -> InstallFlags -> InstallFlags)
-> (InstallFlags -> Flag OnlyConstrained)
-> (Flag OnlyConstrained -> InstallFlags -> InstallFlags)
-> [OptionField InstallFlags]
forall flags.
ShowOrParseArgs
-> (flags -> Flag Int)
-> (Flag Int -> flags -> flags)
-> (flags -> Flag ReorderGoals)
-> (Flag ReorderGoals -> flags -> flags)
-> (flags -> Flag CountConflicts)
-> (Flag CountConflicts -> flags -> flags)
-> (flags -> Flag FineGrainedConflicts)
-> (Flag FineGrainedConflicts -> flags -> flags)
-> (flags -> Flag MinimizeConflictSet)
-> (Flag MinimizeConflictSet -> flags -> flags)
-> (flags -> Flag IndependentGoals)
-> (Flag IndependentGoals -> flags -> flags)
-> (flags -> Flag ShadowPkgs)
-> (Flag ShadowPkgs -> flags -> flags)
-> (flags -> Flag StrongFlags)
-> (Flag StrongFlags -> flags -> flags)
-> (flags -> Flag AllowBootLibInstalls)
-> (Flag AllowBootLibInstalls -> flags -> flags)
-> (flags -> Flag OnlyConstrained)
-> (Flag OnlyConstrained -> flags -> flags)
-> [OptionField flags]
optionSolverFlags ShowOrParseArgs
showOrParseArgs
                        InstallFlags -> Flag Int
installMaxBackjumps     (\Flag Int
v InstallFlags
flags -> InstallFlags
flags { installMaxBackjumps :: Flag Int
installMaxBackjumps     = Flag Int
v })
                        InstallFlags -> Flag ReorderGoals
installReorderGoals     (\Flag ReorderGoals
v InstallFlags
flags -> InstallFlags
flags { installReorderGoals :: Flag ReorderGoals
installReorderGoals     = Flag ReorderGoals
v })
                        InstallFlags -> Flag CountConflicts
installCountConflicts   (\Flag CountConflicts
v InstallFlags
flags -> InstallFlags
flags { installCountConflicts :: Flag CountConflicts
installCountConflicts   = Flag CountConflicts
v })
                        InstallFlags -> Flag FineGrainedConflicts
installFineGrainedConflicts (\Flag FineGrainedConflicts
v InstallFlags
flags -> InstallFlags
flags { installFineGrainedConflicts :: Flag FineGrainedConflicts
installFineGrainedConflicts = Flag FineGrainedConflicts
v })
                        InstallFlags -> Flag MinimizeConflictSet
installMinimizeConflictSet (\Flag MinimizeConflictSet
v InstallFlags
flags -> InstallFlags
flags { installMinimizeConflictSet :: Flag MinimizeConflictSet
installMinimizeConflictSet = Flag MinimizeConflictSet
v })
                        InstallFlags -> Flag IndependentGoals
installIndependentGoals (\Flag IndependentGoals
v InstallFlags
flags -> InstallFlags
flags { installIndependentGoals :: Flag IndependentGoals
installIndependentGoals = Flag IndependentGoals
v })
                        InstallFlags -> Flag ShadowPkgs
installShadowPkgs       (\Flag ShadowPkgs
v InstallFlags
flags -> InstallFlags
flags { installShadowPkgs :: Flag ShadowPkgs
installShadowPkgs       = Flag ShadowPkgs
v })
                        InstallFlags -> Flag StrongFlags
installStrongFlags      (\Flag StrongFlags
v InstallFlags
flags -> InstallFlags
flags { installStrongFlags :: Flag StrongFlags
installStrongFlags      = Flag StrongFlags
v })
                        InstallFlags -> Flag AllowBootLibInstalls
installAllowBootLibInstalls (\Flag AllowBootLibInstalls
v InstallFlags
flags -> InstallFlags
flags { installAllowBootLibInstalls :: Flag AllowBootLibInstalls
installAllowBootLibInstalls = Flag AllowBootLibInstalls
v })
                        InstallFlags -> Flag OnlyConstrained
installOnlyConstrained  (\Flag OnlyConstrained
v InstallFlags
flags -> InstallFlags
flags { installOnlyConstrained :: Flag OnlyConstrained
installOnlyConstrained  = Flag OnlyConstrained
v }) [OptionField InstallFlags]
-> [OptionField InstallFlags] -> [OptionField InstallFlags]
forall a. [a] -> [a] -> [a]
++

      [ String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"reinstall"]
          String
"Install even if it means installing the same version again."
          InstallFlags -> Flag Bool
installReinstall (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installReinstall :: Flag Bool
installReinstall = Flag Bool
v })
          (ShowOrParseArgs
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)

      , String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"avoid-reinstalls"]
          String
"Do not select versions that would destructively overwrite installed packages."
          ((AvoidReinstalls -> Bool) -> Flag AvoidReinstalls -> Flag Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AvoidReinstalls -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag AvoidReinstalls -> Flag Bool)
-> (InstallFlags -> Flag AvoidReinstalls)
-> InstallFlags
-> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InstallFlags -> Flag AvoidReinstalls
installAvoidReinstalls)
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installAvoidReinstalls :: Flag AvoidReinstalls
installAvoidReinstalls = (Bool -> AvoidReinstalls) -> Flag Bool -> Flag AvoidReinstalls
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> AvoidReinstalls
AvoidReinstalls Flag Bool
v })
          (ShowOrParseArgs
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)

      , String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"force-reinstalls"]
          String
"Reinstall packages even if they will most likely break other installed packages."
          InstallFlags -> Flag Bool
installOverrideReinstall (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installOverrideReinstall :: Flag Bool
installOverrideReinstall = Flag Bool
v })
          (ShowOrParseArgs
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)

      , String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"upgrade-dependencies"]
          String
"Pick the latest version for all dependencies, rather than trying to pick an installed version."
          InstallFlags -> Flag Bool
installUpgradeDeps (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installUpgradeDeps :: Flag Bool
installUpgradeDeps = Flag Bool
v })
          (ShowOrParseArgs
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)

      , String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"only-dependencies"]
          String
"Install only the dependencies necessary to build the given packages"
          InstallFlags -> Flag Bool
installOnlyDeps (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags