{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}

-----------------------------------------------------------------------------

-----------------------------------------------------------------------------

-- |
-- 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
  , CheckFlags (..)
  , formatCommand
  , uploadCommand
  , UploadFlags (..)
  , IsCandidate (..)
  , reportCommand
  , ReportFlags (..)
  , runCommand
  , initCommand
  , initOptions
  , IT.InitFlags (..)
  , actAsSetupCommand
  , ActAsSetupFlags (..)
  , userConfigCommand
  , UserConfigFlags (..)
  , manpageCommand
  , haddockCommand
  , cleanCommand
  , copyCommand
  , registerCommand
  , liftOptions
  , yesNoOpt
  ) where

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

import Distribution.Client.Types.AllowNewer (AllowNewer (..), AllowOlder (..), RelaxDeps (..))
import Distribution.Client.Types.Credentials (Password (..), Token (..), Username (..))
import Distribution.Client.Types.Repo (LocalRepo (..), RemoteRepo (..))
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.Defaults as IT
import qualified Distribution.Client.Init.Types as IT
import Distribution.Client.Targets
  ( UserConstraint
  , readUserConstraint
  )
import Distribution.Deprecated.ParseUtils (parseSpaceList, parseTokenQ)
import Distribution.Deprecated.ReadP (readP_to_E)
import Distribution.Utils.NubList
  ( NubList
  , fromNubList
  , toNubList
  )

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

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

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

globalCommand :: [Command action] -> CommandUI GlobalFlags
globalCommand :: forall action. [Command action] -> CommandUI GlobalFlags
globalCommand [Command action]
commands =
  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
"haddock-project"
              , String
"hscolour"
              , String
"exec"
              , String
"path"
              , 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
"new-haddock-project"
              , 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-haddock-project"
              , String
"v2-exec"
              , String
"v2-update"
              , String
"v2-install"
              , String
"v2-clean"
              , String
"v2-sdist"
              ]
          maxlen :: Int
maxlen = [Int] -> Int
forall a. Ord a => [a] -> a
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 a. [a] -> 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 a. [a] -> 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
n String -> 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
"user-config"
                , String -> String
addCmd String
"help"
                , String
par
                , String -> String
startGroup String
"package database"
                , String -> String
addCmd String
"update"
                , String -> String
addCmd String
"list"
                , String -> String
addCmd String
"info"
                , String
par
                , String -> String
startGroup String
"initialization and download"
                , String -> String
addCmd String
"init"
                , String -> String
addCmd String
"fetch"
                , String -> String
addCmd String
"get"
                , String
par
                , String -> String
startGroup String
"project configuration"
                , String -> String
addCmd String
"configure"
                , String -> String
addCmd String
"freeze"
                , String -> String
addCmd String
"gen-bounds"
                , String -> String
addCmd String
"outdated"
                , String -> String
addCmd String
"path"
                , String
par
                , String -> String
startGroup String
"project building and installing"
                , String -> String
addCmd String
"build"
                , String -> String
addCmd String
"install"
                , String -> String
addCmd String
"haddock"
                , String -> String
addCmd String
"haddock-project"
                , String -> String
addCmd String
"clean"
                , String
par
                , String -> String
startGroup String
"running and testing"
                , String -> String
addCmd String
"list-bin"
                , String -> String
addCmd String
"repl"
                , String -> String
addCmd String
"run"
                , String -> String
addCmd String
"bench"
                , String -> String
addCmd String
"test"
                , String -> String
addCmd String
"exec"
                , String
par
                , String -> String
startGroup String
"sanity checks and shipping"
                , String -> String
addCmd String
"check"
                , String -> String
addCmd String
"sdist"
                , String -> String
addCmd String
"upload"
                , String -> String
addCmd String
"report"
                , String
par
                , String -> String
startGroup String
"deprecated"
                , String -> String
addCmd String
"unpack"
                , String -> String
addCmd String
"hscolour"
                , 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-install"
                , String -> String
addCmd String
"v1-clean"
                , 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 a. [a] -> 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 = 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 = 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 = 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 = 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 = 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 = v})
          [ String
-> (Maybe String -> Flag Bool)
-> (Flag Bool -> [Maybe String])
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
forall b a.
Monoid b =>
String
-> (Maybe String -> b)
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg'
              String
"(True or False)"
              (Maybe Bool -> Flag Bool
forall a. Maybe a -> Flag a
maybeToFlag (Maybe Bool -> Flag Bool)
-> (Maybe String -> Maybe Bool) -> Maybe String -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Maybe Bool
forall a. Read a => String -> Maybe a
readMaybe (String -> Maybe Bool) -> Maybe String -> Maybe Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<))
              ( \case
                  Flag Bool
True -> [String -> Maybe String
forall a. a -> Maybe a
Just String
"enable"]
                  Flag Bool
False -> [String -> Maybe String
forall a. a -> Maybe a
Just String
"disable"]
                  Flag Bool
NoFlag -> []
              )
              String
""
              [String
"nix"] -- Must be empty because we need to return PP.empty from viewAsFieldDescr
              String
"[DEPRECATED] Nix integration: run commands through nix-shell if a 'shell.nix' file exists (default is False)"
          , 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
"[DEPRECATED] 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
"[DEPRECATED] 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 = 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 = 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 a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser ActiveRepos
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m ActiveRepos
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 = 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 = 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 = 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 = 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 = 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 = "configure"
    , commandDefaultFlags = mempty
    , commandDescription = Just $ \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
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 = Just $ \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
11, 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
  | Version
cabalLibVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< [Int] -> Version
mkVersion [Int
3, Int
11, Int
0] = ConfigFlags
flags_3_11_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 = []
        }

    flags_3_11_0 :: ConfigFlags
flags_3_11_0 =
      ConfigFlags
flags_latest
        { -- It's too late to convert configPromisedDependencies to anything
          -- meaningful, so we just assert that it's empty.
          -- We add a Cabal>=3.11 constraint before solving when multi-repl is
          -- enabled, so this should never trigger.
          configPromisedDependencies = assert (null $ configPromisedDependencies flags) []
        , -- Cabal < 3.11 does not understand '--coverage-for', which is OK
          -- because previous versions of Cabal using coverage implied
          -- whole-package builds (cuz_coverage), and determine the path to
          -- libraries mix dirs from the testsuite root with a small hack.
          configCoverageFor = NoFlag
        }

    flags_3_7_0 :: ConfigFlags
flags_3_7_0 =
      ConfigFlags
flags_3_11_0
        { -- Cabal < 3.7 does not know about --extra-lib-dirs-static
          configExtraLibDirsStatic = []
        , -- Cabal < 3.7 does not understand '--enable-build-info' or '--disable-build-info'
          configDumpBuildInfo = 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_component=cid
          configDependencies =
            let 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 catMaybes $ convertToLegacyInternalDep <$> configDependencies flags
        , -- Cabal < 2.5 doesn't know about '--allow-depending-on-private-libs'.
          configAllowDependingOnPrivateLibs = NoFlag
        , -- Cabal < 2.5 doesn't know about '--enable/disable-executable-static'.
          configFullyStaticExe = 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 = fmap verboseNoTimestamp (configVerbosity flags_latest)
        , -- Cabal < 2.1 doesn't know about --<enable|disable>-static
          configStaticLib = NoFlag
        , configSplitSections = 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 = configInstallDirs_1_25_0
        , -- Cabal < 1.25 doesn't have extended verbosity syntax
          configVerbosity = fmap verboseNoFlags (configVerbosity flags_2_1_0)
        , -- Cabal < 1.25 doesn't support --deterministic
          configDeterministic = 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 = NoFlag
            , libexecsubdir = NoFlag
            , libexecdir =
                maybeToFlag $
                  combinePathTemplate
                    <$> flagToMaybe (libexecdir dirs)
                    <*> flagToMaybe (libexecsubdir 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 = NoFlag
        , configProfLibDetail = NoFlag
        , configIPID = NoFlag
        , configProf = NoFlag
        , configProfExe = Flag tryExeProfiling
        , configProfLib = Flag 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 = NoFlag
        , configProfExe = 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 = 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 = NoFlag
        , configCoverage = NoFlag
        , configLibCoverage = configCoverage 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 = NoFlag
        , configStripLibs = 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 = []
        , configConstraints = configConstraints 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 = toNubList []
        , configInstallDirs = 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 = 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 = 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 = NoFlag
        , configDynExe = 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 = 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 = []}

-- | 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 = fmap lessVerbose (configVerbosity 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
$c== :: ConfigExFlags -> ConfigExFlags -> Bool
== :: ConfigExFlags -> ConfigExFlags -> Bool
$c/= :: ConfigExFlags -> ConfigExFlags -> Bool
/= :: 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
$cshowsPrec :: Int -> ConfigExFlags -> String -> String
showsPrec :: Int -> ConfigExFlags -> String -> String
$cshow :: ConfigExFlags -> String
show :: ConfigExFlags -> String
$cshowList :: [ConfigExFlags] -> String -> String
showList :: [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
$cfrom :: forall x. ConfigExFlags -> Rep ConfigExFlags x
from :: forall x. ConfigExFlags -> Rep ConfigExFlags x
$cto :: forall x. Rep ConfigExFlags x -> ConfigExFlags
to :: forall x. Rep ConfigExFlags x -> ConfigExFlags
Generic)

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

configureExCommand :: CommandUI (ConfigFlags, ConfigExFlags)
configureExCommand :: CommandUI (ConfigFlags, ConfigExFlags)
configureExCommand =
  CommandUI ConfigFlags
configureCommand
    { commandDefaultFlags = (mempty, defaultConfigExFlags)
    , 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
"promised-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 = 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 a b. (a -> b) -> ParsecParser a -> ParsecParser b
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
forall (m :: * -> *). CabalParsing m => m Version
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 = 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 = 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 = 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 a b. (a -> b) -> ReadE a -> ReadE b
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 = 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 a b. (a -> b) -> ParsecParser a -> ParsecParser b
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
forall (m :: * -> *). CabalParsing m => m PackageVersionConstraint
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 = 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 a b. (a -> b) -> Maybe a -> Maybe b
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 = fmap AllowOlder v})
      ( String
-> ReadE (Maybe RelaxDeps)
-> (String, Maybe RelaxDeps)
-> (Maybe RelaxDeps -> [Maybe String])
-> MkOptDescr
     (ConfigExFlags -> Maybe RelaxDeps)
     (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (String, 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 -> String
forall a. Show a => a -> String
show RelaxDeps
RelaxDepsAll, 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 a b. (a -> b) -> Maybe a -> Maybe b
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 = fmap AllowNewer v})
      ( String
-> ReadE (Maybe RelaxDeps)
-> (String, Maybe RelaxDeps)
-> (Maybe RelaxDeps -> [Maybe String])
-> MkOptDescr
     (ConfigExFlags -> Maybe RelaxDeps)
     (Maybe RelaxDeps -> ConfigExFlags -> ConfigExFlags)
     ConfigExFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (String, 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 -> String
forall a. Show a => a -> String
show RelaxDeps
RelaxDepsAll, 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 = 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 :: forall (m :: * -> *). CabalParsing m => 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
forall (m :: * -> *). CabalParsing m => m RelaxedDep
parsec (Char -> m Char
forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
',')
  if [RelaxedDep] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [RelaxedDep]
rs
    then
      String -> m (Maybe RelaxDeps)
forall a. String -> m a
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 a. a -> m a
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 a. [a] -> [a]
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 = "reconfigure"
    , commandSynopsis = "Reconfigure the package if necessary."
    , commandDescription = Just $ \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 = Just $ \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 = usageAlternatives "v1-reconfigure" ["[FLAGS]"]
    , commandDefaultFlags = mempty
    }

-- ------------------------------------------------------------

-- * Build flags

-- ------------------------------------------------------------

buildCommand :: CommandUI BuildFlags
buildCommand :: CommandUI BuildFlags
buildCommand =
  CommandUI BuildFlags
parent
    { commandName = "build"
    , commandDescription = Just $ \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 = commandDefaultFlags parent
    , commandUsage =
        usageAlternatives "v1-build" $
          ["[FLAGS]", "COMPONENTS [FLAGS]"]
    , commandOptions = commandOptions parent
    , commandNotes = Just $ \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
          Cabal.testWrapper = NoFlag
        }

-- ------------------------------------------------------------

-- * Repl command

-- ------------------------------------------------------------

replCommand :: CommandUI ReplFlags
replCommand :: CommandUI ReplFlags
replCommand =
  CommandUI ReplFlags
parent
    { commandName = "repl"
    , commandDescription = Just $ \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
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 = commandDefaultFlags parent
    , commandOptions = commandOptions parent
    , commandNotes = Just $ \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 = "test"
    , commandDescription = Just $ \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 =
        usageAlternatives
          "v1-test"
          ["[FLAGS]", "TESTCOMPONENTS [FLAGS]"]
    , commandDefaultFlags = (Cabal.defaultBuildFlags, commandDefaultFlags parent)
    , 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 = "bench"
    , commandUsage =
        usageAlternatives
          "v1-bench"
          ["[FLAGS]", "BENCHCOMPONENTS [FLAGS]"]
    , commandDescription = Just $ \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 = (Cabal.defaultBuildFlags, commandDefaultFlags parent)
    , 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 PreferOldest
fetchPreferOldest :: Flag PreferOldest
  , 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
    { --  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)
    , fetchPreferOldest :: Flag PreferOldest
fetchPreferOldest = PreferOldest -> Flag PreferOldest
forall a. a -> Flag a
Flag (Bool -> PreferOldest
PreferOldest 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
    { 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 PreferOldest)
-> (Flag PreferOldest -> 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 PreferOldest)
-> (Flag PreferOldest -> 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 = v})
            FetchFlags -> Flag ReorderGoals
fetchReorderGoals
            (\Flag ReorderGoals
v FetchFlags
flags -> FetchFlags
flags{fetchReorderGoals = v})
            FetchFlags -> Flag CountConflicts
fetchCountConflicts
            (\Flag CountConflicts
v FetchFlags
flags -> FetchFlags
flags{fetchCountConflicts = v})
            FetchFlags -> Flag FineGrainedConflicts
fetchFineGrainedConflicts
            (\Flag FineGrainedConflicts
v FetchFlags
flags -> FetchFlags
flags{fetchFineGrainedConflicts = v})
            FetchFlags -> Flag MinimizeConflictSet
fetchMinimizeConflictSet
            (\Flag MinimizeConflictSet
v FetchFlags
flags -> FetchFlags
flags{fetchMinimizeConflictSet = v})
            FetchFlags -> Flag IndependentGoals
fetchIndependentGoals
            (\Flag IndependentGoals
v FetchFlags
flags -> FetchFlags
flags{fetchIndependentGoals = v})
            FetchFlags -> Flag PreferOldest
fetchPreferOldest
            (\Flag PreferOldest
v FetchFlags
flags -> FetchFlags
flags{fetchPreferOldest = v})
            FetchFlags -> Flag ShadowPkgs
fetchShadowPkgs
            (\Flag ShadowPkgs
v FetchFlags
flags -> FetchFlags
flags{fetchShadowPkgs = v})
            FetchFlags -> Flag StrongFlags
fetchStrongFlags
            (\Flag StrongFlags
v FetchFlags
flags -> FetchFlags
flags{fetchStrongFlags = v})
            FetchFlags -> Flag AllowBootLibInstalls
fetchAllowBootLibInstalls
            (\Flag AllowBootLibInstalls
v FetchFlags
flags -> FetchFlags
flags{fetchAllowBootLibInstalls = v})
            FetchFlags -> Flag OnlyConstrained
fetchOnlyConstrained
            (\Flag OnlyConstrained
v FetchFlags
flags -> FetchFlags
flags{fetchOnlyConstrained = 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 PreferOldest
freezePreferOldest :: Flag PreferOldest
  , 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
    { 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)
    , freezePreferOldest :: Flag PreferOldest
freezePreferOldest = PreferOldest -> Flag PreferOldest
forall a. a -> Flag a
Flag (Bool -> PreferOldest
PreferOldest 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
    { 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 = 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 = 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 = 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 = 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 = 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 PreferOldest)
-> (Flag PreferOldest -> 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 PreferOldest)
-> (Flag PreferOldest -> 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 = v})
            FreezeFlags -> Flag ReorderGoals
freezeReorderGoals
            (\Flag ReorderGoals
v FreezeFlags
flags -> FreezeFlags
flags{freezeReorderGoals = v})
            FreezeFlags -> Flag CountConflicts
freezeCountConflicts
            (\Flag CountConflicts
v FreezeFlags
flags -> FreezeFlags
flags{freezeCountConflicts = v})
            FreezeFlags -> Flag FineGrainedConflicts
freezeFineGrainedConflicts
            (\Flag FineGrainedConflicts
v FreezeFlags
flags -> FreezeFlags
flags{freezeFineGrainedConflicts = v})
            FreezeFlags -> Flag MinimizeConflictSet
freezeMinimizeConflictSet
            (\Flag MinimizeConflictSet
v FreezeFlags
flags -> FreezeFlags
flags{freezeMinimizeConflictSet = v})
            FreezeFlags -> Flag IndependentGoals
freezeIndependentGoals
            (\Flag IndependentGoals
v FreezeFlags
flags -> FreezeFlags
flags{freezeIndependentGoals = v})
            FreezeFlags -> Flag PreferOldest
freezePreferOldest
            (\Flag PreferOldest
v FreezeFlags
flags -> FreezeFlags
flags{freezePreferOldest = v})
            FreezeFlags -> Flag ShadowPkgs
freezeShadowPkgs
            (\Flag ShadowPkgs
v FreezeFlags
flags -> FreezeFlags
flags{freezeShadowPkgs = v})
            FreezeFlags -> Flag StrongFlags
freezeStrongFlags
            (\Flag StrongFlags
v FreezeFlags
flags -> FreezeFlags
flags{freezeStrongFlags = v})
            FreezeFlags -> Flag AllowBootLibInstalls
freezeAllowBootLibInstalls
            (\Flag AllowBootLibInstalls
v FreezeFlags
flags -> FreezeFlags
flags{freezeAllowBootLibInstalls = v})
            FreezeFlags -> Flag OnlyConstrained
freezeOnlyConstrained
            (\Flag OnlyConstrained
v FreezeFlags
flags -> FreezeFlags
flags{freezeOnlyConstrained = v})
    }

-- ------------------------------------------------------------

-- * 'gen-bounds' command

-- ------------------------------------------------------------

genBoundsCommand :: CommandUI FreezeFlags
genBoundsCommand :: CommandUI FreezeFlags
genBoundsCommand =
  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 = v})
        ]
    }

-- ------------------------------------------------------------
-- Check command
-- ------------------------------------------------------------

data CheckFlags = CheckFlags
  { CheckFlags -> Flag Verbosity
checkVerbosity :: Flag Verbosity
  , CheckFlags -> [String]
checkIgnore :: [CheckExplanationIDString]
  }
  deriving (Int -> CheckFlags -> String -> String
[CheckFlags] -> String -> String
CheckFlags -> String
(Int -> CheckFlags -> String -> String)
-> (CheckFlags -> String)
-> ([CheckFlags] -> String -> String)
-> Show CheckFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> CheckFlags -> String -> String
showsPrec :: Int -> CheckFlags -> String -> String
$cshow :: CheckFlags -> String
show :: CheckFlags -> String
$cshowList :: [CheckFlags] -> String -> String
showList :: [CheckFlags] -> String -> String
Show, Typeable)

defaultCheckFlags :: CheckFlags
defaultCheckFlags :: CheckFlags
defaultCheckFlags =
  CheckFlags
    { checkVerbosity :: Flag Verbosity
checkVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal
    , checkIgnore :: [String]
checkIgnore = []
    }

checkCommand :: CommandUI CheckFlags
checkCommand :: CommandUI CheckFlags
checkCommand =
  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
"Some checks correspond to the requirements to packages on Hackage. "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If no `Error` is reported, Hackage should accept the "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"package. If errors are present, `check` exits with 1 and Hackage "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"will refuse the 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 :: CheckFlags
commandDefaultFlags = CheckFlags
defaultCheckFlags
    , commandOptions :: ShowOrParseArgs -> [OptionField CheckFlags]
commandOptions = ShowOrParseArgs -> [OptionField CheckFlags]
checkOptions'
    }

checkOptions' :: ShowOrParseArgs -> [OptionField CheckFlags]
checkOptions' :: ShowOrParseArgs -> [OptionField CheckFlags]
checkOptions' ShowOrParseArgs
_showOrParseArgs =
  [ (CheckFlags -> Flag Verbosity)
-> (Flag Verbosity -> CheckFlags -> CheckFlags)
-> OptionField CheckFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity
      CheckFlags -> Flag Verbosity
checkVerbosity
      (\Flag Verbosity
v CheckFlags
flags -> CheckFlags
flags{checkVerbosity = v})
  , String
-> [String]
-> String
-> (CheckFlags -> [String])
-> ([String] -> CheckFlags -> CheckFlags)
-> MkOptDescr
     (CheckFlags -> [String])
     ([String] -> CheckFlags -> CheckFlags)
     CheckFlags
-> OptionField CheckFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'i']
      [String
"ignore"]
      String
"ignore a specific warning (e.g. --ignore=missing-upper-bounds)"
      CheckFlags -> [String]
checkIgnore
      (\[String]
v CheckFlags
c -> CheckFlags
c{checkIgnore = v ++ checkIgnore c})
      (String
-> (String -> [String])
-> ([String] -> [String])
-> MkOptDescr
     (CheckFlags -> [String])
     ([String] -> CheckFlags -> CheckFlags)
     CheckFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"WARNING" (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: []) ([String] -> [String] -> [String]
forall a b. a -> b -> a
const []))
  ]

-- ------------------------------------------------------------

-- * 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
$cfrom :: forall x. UpdateFlags -> Rep UpdateFlags x
from :: forall x. UpdateFlags -> Rep UpdateFlags x
$cto :: forall x. Rep UpdateFlags x -> UpdateFlags
to :: forall x. Rep UpdateFlags x -> UpdateFlags
Generic)

defaultUpdateFlags :: UpdateFlags
defaultUpdateFlags :: UpdateFlags
defaultUpdateFlags =
  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
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"
    }

formatCommand :: CommandUI (Flag Verbosity)
formatCommand :: CommandUI (Flag Verbosity)
formatCommand =
  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
    { 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
    { 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 Token
reportToken :: Flag Token
  , 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
$cfrom :: forall x. ReportFlags -> Rep ReportFlags x
from :: forall x. ReportFlags -> Rep ReportFlags x
$cto :: forall x. Rep ReportFlags x -> ReportFlags
to :: forall x. Rep ReportFlags x -> ReportFlags
Generic)

defaultReportFlags :: ReportFlags
defaultReportFlags :: ReportFlags
defaultReportFlags =
  ReportFlags
    { reportToken :: Flag Token
reportToken = Flag Token
forall a. Monoid a => a
mempty
    , 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
    { 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 ~/.config/cabal/config file\n"
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"(the %APPDATA%\\cabal\\config file on Windows)\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 = v})
        , String
-> [String]
-> String
-> (ReportFlags -> Flag Token)
-> (Flag Token -> ReportFlags -> ReportFlags)
-> MkOptDescr
     (ReportFlags -> Flag Token)
     (Flag Token -> ReportFlags -> ReportFlags)
     ReportFlags
-> OptionField ReportFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
't']
            [String
"token"]
            String
"Hackage authentication Token."
            ReportFlags -> Flag Token
reportToken
            (\Flag Token
v ReportFlags
flags -> ReportFlags
flags{reportToken = v})
            ( String
-> (String -> Flag Token)
-> (Flag Token -> [String])
-> MkOptDescr
     (ReportFlags -> Flag Token)
     (Flag Token -> ReportFlags -> ReportFlags)
     ReportFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg'
                String
"TOKEN"
                (Token -> Flag Token
forall a. a -> Flag a
toFlag (Token -> Flag Token) -> (String -> Token) -> String -> Flag Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Token
Token)
                (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag Token -> Flag String) -> Flag Token -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Token -> String) -> Flag Token -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Token -> String
unToken)
            )
        , 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 = 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 a b. (a -> b) -> Flag a -> Flag b
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 = 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 a b. (a -> b) -> Flag a -> Flag b
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
getOnlyPkgDescr :: Flag Bool
  , 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
$cfrom :: forall x. GetFlags -> Rep GetFlags x
from :: forall x. GetFlags -> Rep GetFlags x
$cto :: forall x. Rep GetFlags x -> GetFlags
to :: forall x. Rep GetFlags x -> GetFlags
Generic)

defaultGetFlags :: GetFlags
defaultGetFlags :: GetFlags
defaultGetFlags =
  GetFlags
    { getDestDir :: Flag String
getDestDir = Flag String
forall a. Monoid a => a
mempty
    , getOnlyPkgDescr :: Flag Bool
getOnlyPkgDescr = Flag Bool
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
    { 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 = 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 = 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 = v})
            ( String
-> ReadE (Flag (Maybe RepoKind))
-> (String, 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
-> (String, 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 a b. (a -> b) -> ParsecParser a -> ParsecParser b
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
forall (m :: * -> *). CabalParsing m => m RepoKind
parsec)
                )
                (String
"", 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 a b. (a -> b) -> Maybe a -> Maybe b
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 = 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 a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser TotalIndexState
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m TotalIndexState
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 a b. (a -> b) -> Flag a -> Flag b
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
"only-package-description"]
            String
"Unpack only the package description file."
            GetFlags -> Flag Bool
getOnlyPkgDescr
            (\Flag Bool
v GetFlags
flags -> GetFlags
flags{getOnlyPkgDescr = v})
            MkOptDescr
  (GetFlags -> Flag Bool)
  (Flag Bool -> GetFlags -> GetFlags)
  GetFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
        , 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
"package-description-only"]
            String
"A synonym for --only-package-description."
            GetFlags -> Flag Bool
getOnlyPkgDescr
            (\Flag Bool
v GetFlags
flags -> GetFlags
flags{getOnlyPkgDescr = v})
            MkOptDescr
  (GetFlags -> Flag Bool)
  (Flag Bool -> GetFlags -> GetFlags)
  GetFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
        , 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 = 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 = "unpack"
    , commandSynopsis = synopsis
    , commandNotes = Just $ \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 = usagePackages "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
$cfrom :: forall x. ListFlags -> Rep ListFlags x
from :: forall x. ListFlags -> Rep ListFlags x
$cto :: forall x. Rep ListFlags x -> ListFlags
to :: forall x. Rep ListFlags x -> ListFlags
Generic)

defaultListFlags :: ListFlags
defaultListFlags :: ListFlags
defaultListFlags =
  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
    { 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 = 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 = 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 = 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 = 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 = 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 = 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
$cfrom :: forall x. InfoFlags -> Rep InfoFlags x
from :: forall x. InfoFlags -> Rep InfoFlags x
$cto :: forall x. Rep InfoFlags x -> InfoFlags
to :: forall x. Rep InfoFlags x -> InfoFlags
Generic)

defaultInfoFlags :: InfoFlags
defaultInfoFlags :: InfoFlags
defaultInfoFlags =
  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
    { 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 = 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 = 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 PreferOldest
installPreferOldest :: Flag PreferOldest
  , 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
installUseSemaphore :: Flag Bool
  , 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
$c== :: InstallFlags -> InstallFlags -> Bool
== :: InstallFlags -> InstallFlags -> Bool
$c/= :: InstallFlags -> InstallFlags -> Bool
/= :: 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
$cshowsPrec :: Int -> InstallFlags -> String -> String
showsPrec :: Int -> InstallFlags -> String -> String
$cshow :: InstallFlags -> String
show :: InstallFlags -> String
$cshowList :: [InstallFlags] -> String -> String
showList :: [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
$cfrom :: forall x. InstallFlags -> Rep InstallFlags x
from :: forall x. InstallFlags -> Rep InstallFlags x
$cto :: forall x. Rep InstallFlags x -> InstallFlags
to :: forall x. Rep InstallFlags x -> InstallFlags
Generic)

instance Binary InstallFlags

defaultInstallFlags :: InstallFlags
defaultInstallFlags :: InstallFlags
defaultInstallFlags =
  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)
    , installPreferOldest :: Flag PreferOldest
installPreferOldest = PreferOldest -> Flag PreferOldest
forall a. a -> Flag a
Flag (Bool -> PreferOldest
PreferOldest 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
    , installUseSemaphore :: Flag Bool
installUseSemaphore = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False
    , 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
    { 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 `~/.local/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", "promised-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
"promised-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 =
        usageAlternatives "v1-haddock" $
          ["[FLAGS]", "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 = []
        }

haddockOptions :: ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions :: ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions ShowOrParseArgs
showOrParseArgs =
  [ OptionField HaddockFlags
opt
    { optionName = "haddock-" ++ name
    , optionDescr =
        [ 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)) descr
        | descr <- optionDescr 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 a. Eq a => a -> [a] -> 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
"use-index"
             , String
"for-hackage"
             , String
"base-url"
             , String
"lib"
             , String
"output-dir"
             ]
  ]

testOptions :: ShowOrParseArgs -> [OptionField TestFlags]
testOptions :: ShowOrParseArgs -> [OptionField TestFlags]
testOptions ShowOrParseArgs
showOrParseArgs =
  [ OptionField TestFlags
opt
    { optionName = prefixTest name
    , optionDescr =
        [ fmapOptFlags (\(String
_, [String]
lflags) -> ([], (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map String -> String
prefixTest [String]
lflags)) descr
        | descr <- optionDescr 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 a. Eq a => a -> [a] -> 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 = prefixBenchmark name
    , optionDescr =
        [ fmapOptFlags (\(String
_, [String]
lflags) -> ([], (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map String -> String
prefixBenchmark [String]
lflags)) descr
        | descr <- optionDescr 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 a. Eq a => a -> [a] -> 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 :: forall a. (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 (String, a -> a)
i a -> [Maybe String]
w) = String
-> OptFlags
-> String
-> ReadE (a -> a)
-> (String, a -> a)
-> (a -> [Maybe String])
-> OptDescr a
forall a.
String
-> OptFlags
-> String
-> ReadE (a -> a)
-> (String, a -> a)
-> (a -> [Maybe String])
-> OptDescr a
OptArg String
d (OptFlags -> OptFlags
modify OptFlags
f) String
p ReadE (a -> a)
r (String, 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 = 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 = 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 a b. (a -> b) -> Flag a -> Flag b
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 = 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 = 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 = 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 PreferOldest)
-> (Flag PreferOldest -> 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 PreferOldest)
-> (Flag PreferOldest -> 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 = v})
      InstallFlags -> Flag ReorderGoals
installReorderGoals
      (\Flag ReorderGoals
v InstallFlags
flags -> InstallFlags
flags{installReorderGoals = v})
      InstallFlags -> Flag CountConflicts
installCountConflicts
      (\Flag CountConflicts
v InstallFlags
flags -> InstallFlags
flags{installCountConflicts = v})
      InstallFlags -> Flag FineGrainedConflicts
installFineGrainedConflicts
      (\Flag FineGrainedConflicts
v InstallFlags
flags -> InstallFlags
flags{installFineGrainedConflicts = v})
      InstallFlags -> Flag MinimizeConflictSet
installMinimizeConflictSet
      (\Flag MinimizeConflictSet
v InstallFlags
flags -> InstallFlags
flags{installMinimizeConflictSet = v})
      InstallFlags -> Flag IndependentGoals
installIndependentGoals
      (\Flag IndependentGoals
v InstallFlags
flags -> InstallFlags
flags{installIndependentGoals = v})
      InstallFlags -> Flag PreferOldest
installPreferOldest
      (\Flag PreferOldest
v InstallFlags
flags -> InstallFlags
flags{installPreferOldest = v})
      InstallFlags -> Flag ShadowPkgs
installShadowPkgs
      (\Flag ShadowPkgs
v InstallFlags
flags -> InstallFlags
flags{installShadowPkgs = v})
      InstallFlags -> Flag StrongFlags
installStrongFlags
      (\Flag StrongFlags
v InstallFlags
flags -> InstallFlags
flags{installStrongFlags = v})
      InstallFlags -> Flag AllowBootLibInstalls
installAllowBootLibInstalls
      (\Flag AllowBootLibInstalls
v InstallFlags
flags -> InstallFlags
flags{installAllowBootLibInstalls = v})
      InstallFlags -> Flag OnlyConstrained
installOnlyConstrained
      (\Flag OnlyConstrained
v InstallFlags
flags -> InstallFlags
flags{installOnlyConstrained = 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 = 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 a b. (a -> b) -> Flag a -> Flag b
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 = fmap AvoidReinstalls 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 = 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 = 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{installOnlyDeps = 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
"dependencies-only"]
          String
"A synonym for --only-dependencies"
          InstallFlags -> Flag Bool
installOnlyDeps
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installOnlyDeps = 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 TotalIndexState)
-> (Flag TotalIndexState -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag TotalIndexState)
     (Flag TotalIndexState -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
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')."
          )
          InstallFlags -> Flag TotalIndexState
installIndexState
          (\Flag TotalIndexState
v InstallFlags
flags -> InstallFlags
flags{installIndexState = v})
          ( String
-> ReadE (Flag TotalIndexState)
-> (Flag TotalIndexState -> [String])
-> MkOptDescr
     (InstallFlags -> Flag TotalIndexState)
     (Flag TotalIndexState -> InstallFlags -> InstallFlags)
     InstallFlags
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 a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser TotalIndexState
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m TotalIndexState
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 a b. (a -> b) -> Flag a -> Flag b
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
-> (InstallFlags -> Flag String)
-> (Flag String -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag String)
     (Flag String -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
          []
          [String
"root-cmd"]
          String
"(No longer supported, do not use.)"
          InstallFlags -> Flag String
installRootCmd
          (\Flag String
v InstallFlags
flags -> InstallFlags
flags{installRootCmd = v})
          (String
-> (String -> Flag String)
-> (Flag String -> [String])
-> MkOptDescr
     (InstallFlags -> Flag String)
     (Flag String -> InstallFlags -> InstallFlags)
     InstallFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"COMMAND" String -> Flag String
forall a. a -> Flag a
toFlag Flag String -> [String]
forall a. Flag a -> [a]
flagToList)
       , String
-> [String]
-> String
-> (InstallFlags -> Flag String)
-> (Flag String -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag String)
     (Flag String -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
          []
          [String
"symlink-bindir"]
          String
"Add symlinks to installed executables into this directory."
          InstallFlags -> Flag String
installSymlinkBinDir
          (\Flag String
v InstallFlags
flags -> InstallFlags
flags{installSymlinkBinDir = v})
          (String
-> MkOptDescr
     (InstallFlags -> Flag String)
     (Flag String -> InstallFlags -> InstallFlags)
     InstallFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"DIR")
       , String
-> [String]
-> String
-> (InstallFlags -> NubList PathTemplate)
-> (NubList PathTemplate -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> NubList PathTemplate)
     (NubList PathTemplate -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
          []
          [String
"build-summary"]
          String
"Save build summaries to file (name template can use $pkgid, $compiler, $os, $arch)"
          InstallFlags -> NubList PathTemplate
installSummaryFile
          (\NubList PathTemplate
v InstallFlags
flags -> InstallFlags
flags{installSummaryFile = v})
          (String
-> (String -> NubList PathTemplate)
-> (NubList PathTemplate -> [String])
-> MkOptDescr
     (InstallFlags -> NubList PathTemplate)
     (NubList PathTemplate -> InstallFlags -> InstallFlags)
     InstallFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"TEMPLATE" (\String
x -> [PathTemplate] -> NubList PathTemplate
forall a. Ord a => [a] -> NubList a
toNubList [String -> PathTemplate
toPathTemplate String
x]) ((PathTemplate -> String) -> [PathTemplate] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map PathTemplate -> String
fromPathTemplate ([PathTemplate] -> [String])
-> (NubList PathTemplate -> [PathTemplate])
-> NubList PathTemplate
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NubList PathTemplate -> [PathTemplate]
forall a. NubList a -> [a]
fromNubList))
       , 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
"build-log"]
          String
"Log all builds to file (name template can use $pkgid, $compiler, $os, $arch)"
          InstallFlags -> Flag PathTemplate
installLogFile
          (\Flag PathTemplate
v InstallFlags
flags -> InstallFlags
flags{installLogFile = 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 a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PathTemplate -> String
fromPathTemplate)
          )
       , String
-> [String]
-> String
-> (InstallFlags -> Flag ReportLevel)
-> (Flag ReportLevel -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag ReportLevel)
     (Flag ReportLevel -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
          []
          [String
"remote-build-reporting"]
          String
"Generate build reports to send to a remote server (none, anonymous or detailed)."
          InstallFlags -> Flag ReportLevel
installBuildReports
          (\Flag ReportLevel
v InstallFlags
flags -> InstallFlags
flags{installBuildReports = v})
          ( String
-> ReadE (Flag ReportLevel)
-> (Flag ReportLevel -> [String])
-> MkOptDescr
     (InstallFlags -> Flag ReportLevel)
     (Flag ReportLevel -> InstallFlags -> InstallFlags)
     InstallFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
              String
"LEVEL"
              ( (String -> String)
-> ParsecParser (Flag ReportLevel) -> ReadE (Flag ReportLevel)
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
"report level must be 'none', "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"'anonymous' or 'detailed'"
                  )
                  (ReportLevel -> Flag ReportLevel
forall a. a -> Flag a
toFlag (ReportLevel -> Flag ReportLevel)
-> ParsecParser ReportLevel -> ParsecParser (Flag ReportLevel)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser ReportLevel
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m ReportLevel
parsec)
              )
              (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag ReportLevel -> Flag String)
-> Flag ReportLevel
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ReportLevel -> String) -> Flag ReportLevel -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ReportLevel -> String
forall a. Pretty a => a -> String
prettyShow)
          )
       , 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
"report-planning-failure"]
          String
"Generate build reports when the dependency solver fails. This is used by the Hackage build bot."
          InstallFlags -> Flag Bool
installReportPlanningFailure
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installReportPlanningFailure = 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
""
          [String
"per-component"]
          String
"Per-component builds when possible"
          InstallFlags -> Flag Bool
installPerComponent
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installPerComponent = 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 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
"run-tests"]
          String
"Run package test suites during installation."
          InstallFlags -> Flag Bool
installRunTests
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installRunTests = 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
"semaphore"]
          String
"Use a semaphore so GHC can compile components in parallel"
          InstallFlags -> Flag Bool
installUseSemaphore
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installUseSemaphore = 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)
       , (InstallFlags -> Flag (Maybe Int))
-> (Flag (Maybe Int) -> InstallFlags -> InstallFlags)
-> OptionField InstallFlags
forall flags.
(flags -> Flag (Maybe Int))
-> (Flag (Maybe Int) -> flags -> flags) -> OptionField flags
optionNumJobs
          InstallFlags -> Flag (Maybe Int)
installNumJobs
          (\Flag (Maybe Int)
v InstallFlags
flags -> InstallFlags
flags{installNumJobs = v})
       , 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
"keep-going"]
          String
"After a build failure, continue to build other unaffected packages."
          InstallFlags -> Flag Bool
installKeepGoing
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installKeepGoing = 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
"offline"]
          String
"Don't download packages from the Internet."
          InstallFlags -> Flag Bool
installOfflineMode
          (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installOfflineMode = 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)
       ]
    [OptionField InstallFlags]
-> [OptionField InstallFlags] -> [OptionField InstallFlags]
forall a. [a] -> [a] -> [a]
++ case ShowOrParseArgs
showOrParseArgs of -- TODO: remove when "cabal install"
    -- avoids
      ShowOrParseArgs
ParseArgs ->
        [ 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"]
            String
"Only installs the package in the current directory."
            InstallFlags -> Flag Bool
installOnly
            (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags{installOnly = v})
            MkOptDescr
  (InstallFlags -> Flag Bool)
  (Flag Bool -> InstallFlags -> InstallFlags)
  InstallFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
        ]
      ShowOrParseArgs
_ -> []

optionNumJobs
  :: (flags -> Flag (Maybe Int))
  -> (Flag (Maybe Int) -> flags -> flags)
  -> OptionField flags
optionNumJobs :: forall flags.
(flags -> Flag (Maybe Int))
-> (Flag (Maybe Int) -> flags -> flags) -> OptionField flags
optionNumJobs flags -> Flag (Maybe Int)
get Flag (Maybe Int) -> flags -> flags
set =
  String
-> [String]
-> String
-> (flags -> Flag (Maybe Int))
-> (Flag (Maybe Int) -> flags -> flags)
-> MkOptDescr
     (flags -> Flag (Maybe Int))
     (Flag (Maybe Int) -> flags -> flags)
     flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
    String
"j"
    [String
"jobs"]
    String
"Run NUM jobs simultaneously (or '$ncpus' if no NUM is given)."
    flags -> Flag (Maybe Int)
get
    Flag (Maybe Int) -> flags -> flags
set
    ( String
-> ReadE (Flag (Maybe Int))
-> (String, Flag (Maybe Int))
-> (Flag (Maybe Int) -> [Maybe String])
-> MkOptDescr
     (flags -> Flag (Maybe Int))
     (Flag (Maybe Int) -> flags -> flags)
     flags
forall b a.
Monoid b =>
String
-> ReadE b
-> (String, b)
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg
        String
"NUM"
        ((Maybe Int -> Flag (Maybe Int))
-> ReadE (Maybe Int) -> ReadE (Flag (Maybe Int))
forall a b. (a -> b) -> ReadE a -> ReadE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Maybe Int -> Flag (Maybe Int)
forall a. a -> Flag a
Flag ReadE (Maybe Int)
numJobsParser)
        (String
"", Maybe Int -> Flag (Maybe Int)
forall a. a -> Flag a
Flag Maybe Int
forall a. Maybe a
Nothing)
        ((Maybe Int -> Maybe String) -> [Maybe Int] -> [Maybe String]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String)
-> (Maybe Int -> String) -> Maybe Int -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> (Int -> String) -> Maybe Int -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"$ncpus" Int -> String
forall a. Show a => a -> String
show) ([Maybe Int] -> [Maybe String])
-> (Flag (Maybe Int) -> [Maybe Int])
-> Flag (Maybe Int)
-> [Maybe String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag (Maybe Int) -> [Maybe Int]
forall a. Flag a -> [a]
flagToList)
    )
  where
    numJobsParser :: ReadE (Maybe Int)
    numJobsParser :: ReadE (Maybe Int)
numJobsParser = (String -> Either String (Maybe Int)) -> ReadE (Maybe Int)
forall a. (String -> Either String a) -> ReadE a
ReadE ((String -> Either String (Maybe Int)) -> ReadE (Maybe Int))
-> (String -> Either String (Maybe Int)) -> ReadE (Maybe Int)
forall a b. (a -> b) -> a -> b
$ \String
s ->
      case String
s of
        String
"$ncpus" -> Maybe Int -> Either String (Maybe Int)
forall a b. b -> Either a b
Right Maybe Int
forall a. Maybe a
Nothing
        String
_ -> case ReadS Int
forall a. Read a => ReadS a
reads String
s of
          [(Int
n, String
"")]
            | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
1 -> String -> Either String (Maybe Int)
forall a b. a -> Either a b
Left String
"The number of jobs should be 1 or more."
            | Bool
otherwise -> Maybe Int -> Either String (Maybe Int)
forall a b. b -> Either a b
Right (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
n)
          [(Int, String)]
_ -> String -> Either String (Maybe Int)
forall a b. a -> Either a b
Left String
"The jobs value should be a number or '$ncpus'"

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

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

-- ------------------------------------------------------------

-- * Upload flags

-- ------------------------------------------------------------

-- | Is this a candidate package or a package to be published?
data IsCandidate = IsCandidate | IsPublished
  deriving (IsCandidate -> IsCandidate -> Bool
(IsCandidate -> IsCandidate -> Bool)
-> (IsCandidate -> IsCandidate -> Bool) -> Eq IsCandidate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IsCandidate -> IsCandidate -> Bool
== :: IsCandidate -> IsCandidate -> Bool
$c/= :: IsCandidate -> IsCandidate -> Bool
/= :: IsCandidate -> IsCandidate -> Bool
Eq)

data UploadFlags = UploadFlags
  { UploadFlags -> Flag IsCandidate
uploadCandidate :: Flag IsCandidate
  , UploadFlags -> Flag Bool
uploadDoc :: Flag Bool
  , UploadFlags -> Flag Token
uploadToken :: Flag Token
  , UploadFlags -> Flag Username
uploadUsername :: Flag Username
  , UploadFlags -> Flag Password
uploadPassword :: Flag Password
  , UploadFlags -> Flag [String]
uploadPasswordCmd :: Flag [String]
  , UploadFlags -> Flag Verbosity
uploadVerbosity :: Flag Verbosity
  }
  deriving ((forall x. UploadFlags -> Rep UploadFlags x)
-> (forall x. Rep UploadFlags x -> UploadFlags)
-> Generic UploadFlags
forall x. Rep UploadFlags x -> UploadFlags
forall x. UploadFlags -> Rep UploadFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UploadFlags -> Rep UploadFlags x
from :: forall x. UploadFlags -> Rep UploadFlags x
$cto :: forall x. Rep UploadFlags x -> UploadFlags
to :: forall x. Rep UploadFlags x -> UploadFlags
Generic)

defaultUploadFlags :: UploadFlags
defaultUploadFlags :: UploadFlags
defaultUploadFlags =
  UploadFlags
    { uploadCandidate :: Flag IsCandidate
uploadCandidate = IsCandidate -> Flag IsCandidate
forall a. a -> Flag a
toFlag IsCandidate
IsCandidate
    , uploadDoc :: Flag Bool
uploadDoc = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False
    , uploadToken :: Flag Token
uploadToken = Flag Token
forall a. Monoid a => a
mempty
    , uploadUsername :: Flag Username
uploadUsername = Flag Username
forall a. Monoid a => a
mempty
    , uploadPassword :: Flag Password
uploadPassword = Flag Password
forall a. Monoid a => a
mempty
    , uploadPasswordCmd :: Flag [String]
uploadPasswordCmd = Flag [String]
forall a. Monoid a => a
mempty
    , uploadVerbosity :: Flag Verbosity
uploadVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal
    }

uploadCommand :: CommandUI UploadFlags
uploadCommand :: CommandUI UploadFlags
uploadCommand =
  CommandUI
    { commandName :: String
commandName = String
"upload"
    , commandSynopsis :: String
commandSynopsis = String
"Uploads source packages or documentation to Hackage."
    , 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 ~/.config/cabal/config file\n"
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"(the %APPDATA%\\cabal\\config file on Windows)\n"
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
relevantConfigValuesText [String
"token", String
"username", String
"password", String
"password-command"]
    , 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
" upload [FLAGS] TARFILES\n"
    , commandDefaultFlags :: UploadFlags
commandDefaultFlags = UploadFlags
defaultUploadFlags
    , commandOptions :: ShowOrParseArgs -> [OptionField UploadFlags]
commandOptions = \ShowOrParseArgs
_ ->
        [ (UploadFlags -> Flag Verbosity)
-> (Flag Verbosity -> UploadFlags -> UploadFlags)
-> OptionField UploadFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity
            UploadFlags -> Flag Verbosity
uploadVerbosity
            (\Flag Verbosity
v UploadFlags
flags -> UploadFlags
flags{uploadVerbosity = v})
        , String
-> [String]
-> String
-> (UploadFlags -> Flag IsCandidate)
-> (Flag IsCandidate -> UploadFlags -> UploadFlags)
-> MkOptDescr
     (UploadFlags -> Flag IsCandidate)
     (Flag IsCandidate -> UploadFlags -> UploadFlags)
     UploadFlags
-> OptionField UploadFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            []
            [String
"publish"]
            String
"Publish the package instead of uploading it as a candidate."
            UploadFlags -> Flag IsCandidate
uploadCandidate
            (\Flag IsCandidate
v UploadFlags
flags -> UploadFlags
flags{uploadCandidate = v})
            (Flag IsCandidate
-> MkOptDescr
     (UploadFlags -> Flag IsCandidate)
     (Flag IsCandidate -> UploadFlags -> UploadFlags)
     UploadFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (IsCandidate -> Flag IsCandidate
forall a. a -> Flag a
Flag IsCandidate
IsPublished))
        , String
-> [String]
-> String
-> (UploadFlags -> Flag Bool)
-> (Flag Bool -> UploadFlags -> UploadFlags)
-> MkOptDescr
     (UploadFlags -> Flag Bool)
     (Flag Bool -> UploadFlags -> UploadFlags)
     UploadFlags
-> OptionField UploadFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
'd']
            [String
"documentation"]
            ( String
"Upload documentation instead of a source package. "
                String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"By default, this uploads documentation for a package candidate. "
                String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"To upload documentation for "
                String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"a published package, combine with --publish."
            )
            UploadFlags -> Flag Bool
uploadDoc
            (\Flag Bool
v UploadFlags
flags -> UploadFlags
flags{uploadDoc = v})
            MkOptDescr
  (UploadFlags -> Flag Bool)
  (Flag Bool -> UploadFlags -> UploadFlags)
  UploadFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
        , String
-> [String]
-> String
-> (UploadFlags -> Flag Token)
-> (Flag Token -> UploadFlags -> UploadFlags)
-> MkOptDescr
     (UploadFlags -> Flag Token)
     (Flag Token -> UploadFlags -> UploadFlags)
     UploadFlags
-> OptionField UploadFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
't']
            [String
"token"]
            String
"Hackage authentication token."
            UploadFlags -> Flag Token
uploadToken
            (\Flag Token
v UploadFlags
flags -> UploadFlags
flags{uploadToken = v})
            ( String
-> (String -> Flag Token)
-> (Flag Token -> [String])
-> MkOptDescr
     (UploadFlags -> Flag Token)
     (Flag Token -> UploadFlags -> UploadFlags)
     UploadFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg'
                String
"TOKEN"
                (Token -> Flag Token
forall a. a -> Flag a
toFlag (Token -> Flag Token) -> (String -> Token) -> String -> Flag Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Token
Token)
                (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag Token -> Flag String) -> Flag Token -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Token -> String) -> Flag Token -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Token -> String
unToken)
            )
        , String
-> [String]
-> String
-> (UploadFlags -> Flag Username)
-> (Flag Username -> UploadFlags -> UploadFlags)
-> MkOptDescr
     (UploadFlags -> Flag Username)
     (Flag Username -> UploadFlags -> UploadFlags)
     UploadFlags
-> OptionField UploadFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
'u']
            [String
"username"]
            String
"Hackage username."
            UploadFlags -> Flag Username
uploadUsername
            (\Flag Username
v UploadFlags
flags -> UploadFlags
flags{uploadUsername = v})
            ( String
-> (String -> Flag Username)
-> (Flag Username -> [String])
-> MkOptDescr
     (UploadFlags -> Flag Username)
     (Flag Username -> UploadFlags -> UploadFlags)
     UploadFlags
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 a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Username -> String
unUsername)
            )
        , String
-> [String]
-> String
-> (UploadFlags -> Flag Password)
-> (Flag Password -> UploadFlags -> UploadFlags)
-> MkOptDescr
     (UploadFlags -> Flag Password)
     (Flag Password -> UploadFlags -> UploadFlags)
     UploadFlags
-> OptionField UploadFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
'p']
            [String
"password"]
            String
"Hackage password."
            UploadFlags -> Flag Password
uploadPassword
            (\Flag Password
v UploadFlags
flags -> UploadFlags
flags{uploadPassword = v})
            ( String
-> (String -> Flag Password)
-> (Flag Password -> [String])
-> MkOptDescr
     (UploadFlags -> Flag Password)
     (Flag Password -> UploadFlags -> UploadFlags)
     UploadFlags
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 a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Password -> String
unPassword)
            )
        , String
-> [String]
-> String
-> (UploadFlags -> Flag [String])
-> (Flag [String] -> UploadFlags -> UploadFlags)
-> MkOptDescr
     (UploadFlags -> Flag [String])
     (Flag [String] -> UploadFlags -> UploadFlags)
     UploadFlags
-> OptionField UploadFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
'P']
            [String
"password-command"]
            String
"Command to get Hackage password."
            UploadFlags -> Flag [String]
uploadPasswordCmd
            (\Flag [String]
v UploadFlags
flags -> UploadFlags
flags{uploadPasswordCmd = v})
            ( String
-> ReadE (Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (UploadFlags -> Flag [String])
     (Flag [String] -> UploadFlags -> UploadFlags)
     UploadFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
                String
"COMMAND"
                ( (String -> String)
-> ReadP (Flag [String]) (Flag [String]) -> ReadE (Flag [String])
forall a. (String -> String) -> ReadP a a -> ReadE a
readP_to_E
                    (String
"Cannot parse command: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
                    ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> Parser (Flag [String]) Char [String]
-> ReadP (Flag [String]) (Flag [String])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadP (Flag [String]) String
-> Parser (Flag [String]) Char [String]
forall r a. ReadP r a -> ReadP r [a]
parseSpaceList ReadP (Flag [String]) String
forall r. ReadP r String
parseTokenQ)
                )
                ([String] -> ([String] -> [String]) -> Flag [String] -> [String]
forall b a. b -> (a -> b) -> Flag a -> b
flagElim [] (String -> [String]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure (String -> [String])
-> ([String] -> String) -> [String] -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
unwords ([String] -> String)
-> ([String] -> [String]) -> [String] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> String
forall a. Show a => a -> String
show))
            )
        ]
    }

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

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

-- ------------------------------------------------------------

-- * Init flags

-- ------------------------------------------------------------

initCommand :: CommandUI IT.InitFlags
initCommand :: CommandUI InitFlags
initCommand =
  CommandUI
    { commandName :: String
commandName = String
"init"
    , commandSynopsis :: String
commandSynopsis = String
"Create a new cabal 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
"Create a .cabal, CHANGELOG.md, minimal initial Haskell code and optionally a LICENSE file.\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Calling init with no arguments runs interactive mode, "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"which will try to guess as much as possible and prompt you for the rest.\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Non-interactive mode can be invoked by the -n/--non-interactive flag, "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"which will let you specify the options via flags and will use the defaults for the rest.\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"It is also possible to call init with a single argument, which denotes the project's desired "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"root directory.\n"
    , commandNotes :: Maybe (String -> String)
commandNotes = Maybe (String -> String)
forall a. Maybe a
Nothing
    , 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
" init [PROJECT ROOT] [FLAGS]\n"
    , commandDefaultFlags :: InitFlags
commandDefaultFlags = InitFlags
IT.defaultInitFlags
    , commandOptions :: ShowOrParseArgs -> [OptionField InitFlags]
commandOptions = ShowOrParseArgs -> [OptionField InitFlags]
initOptions
    }

initOptions :: ShowOrParseArgs -> [OptionField IT.InitFlags]
initOptions :: ShowOrParseArgs -> [OptionField InitFlags]
initOptions ShowOrParseArgs
_ =
  [ String
-> [String]
-> String
-> (InitFlags -> Flag Bool)
-> (Flag Bool -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'i']
      [String
"interactive"]
      String
"interactive mode."
      InitFlags -> Flag Bool
IT.interactive
      (\Flag Bool
v InitFlags
flags -> InitFlags
flags{IT.interactive = v})
      (OptFlags
-> OptFlags
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
forall a.
OptFlags
-> OptFlags -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt' ([Char
'i'], [String
"interactive"]) ([Char
'n'], [String
"non-interactive"]))
  , String
-> [String]
-> String
-> (InitFlags -> Flag Bool)
-> (Flag Bool -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'q']
      [String
"quiet"]
      String
"Do not generate log messages to stdout."
      InitFlags -> Flag Bool
IT.quiet
      (\Flag Bool
v InitFlags
flags -> InitFlags
flags{IT.quiet = v})
      MkOptDescr
  (InitFlags -> Flag Bool)
  (Flag Bool -> InitFlags -> InitFlags)
  InitFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
  , String
-> [String]
-> String
-> (InitFlags -> Flag Bool)
-> (Flag Bool -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"no-comments"]
      String
"Do not generate explanatory comments in the .cabal file."
      InitFlags -> Flag Bool
IT.noComments
      (\Flag Bool
v InitFlags
flags -> InitFlags
flags{IT.noComments = v})
      MkOptDescr
  (InitFlags -> Flag Bool)
  (Flag Bool -> InitFlags -> InitFlags)
  InitFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
  , String
-> [String]
-> String
-> (InitFlags -> Flag Bool)
-> (Flag Bool -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'm']
      [String
"minimal"]
      String
"Generate a minimal .cabal file, that is, do not include extra empty fields.  Also implies --no-comments."
      InitFlags -> Flag Bool
IT.minimal
      (\Flag Bool
v InitFlags
flags -> InitFlags
flags{IT.minimal = v})
      MkOptDescr
  (InitFlags -> Flag Bool)
  (Flag Bool -> InitFlags -> InitFlags)
  InitFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
  , String
-> [String]
-> String
-> (InitFlags -> Flag Bool)
-> (Flag Bool -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"overwrite"]
      String
"Overwrite any existing .cabal, LICENSE, or Setup.hs files without warning."
      InitFlags -> Flag Bool
IT.overwrite
      (\Flag Bool
v InitFlags
flags -> InitFlags
flags{IT.overwrite = v})
      MkOptDescr
  (InitFlags -> Flag Bool)
  (Flag Bool -> InitFlags -> InitFlags)
  InitFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"package-dir", String
"packagedir"]
      String
"Root directory of the package (default = current directory)."
      InitFlags -> Flag String
IT.packageDir
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.packageDir = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"DIRECTORY")
  , String
-> [String]
-> String
-> (InitFlags -> Flag PackageName)
-> (Flag PackageName -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag PackageName)
     (Flag PackageName -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'p']
      [String
"package-name"]
      String
"Name of the Cabal package to create."
      InitFlags -> Flag PackageName
IT.packageName
      (\Flag PackageName
v InitFlags
flags -> InitFlags
flags{IT.packageName = v})
      ( String
-> ReadE (Flag PackageName)
-> (Flag PackageName -> [String])
-> MkOptDescr
     (InitFlags -> Flag PackageName)
     (Flag PackageName -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
          String
"PACKAGE"
          ( (String -> String)
-> ParsecParser (Flag PackageName) -> ReadE (Flag PackageName)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
              (String
"Cannot parse package name: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
              (PackageName -> Flag PackageName
forall a. a -> Flag a
toFlag (PackageName -> Flag PackageName)
-> ParsecParser PackageName -> ParsecParser (Flag PackageName)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser PackageName
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m PackageName
parsec)
          )
          (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag PackageName -> Flag String)
-> Flag PackageName
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PackageName -> String) -> Flag PackageName -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PackageName -> String
forall a. Pretty a => a -> String
prettyShow)
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag Version)
-> (Flag Version -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Version)
     (Flag Version -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"version"]
      String
"Initial version of the package."
      InitFlags -> Flag Version
IT.version
      (\Flag Version
v InitFlags
flags -> InitFlags
flags{IT.version = v})
      ( String
-> ReadE (Flag Version)
-> (Flag Version -> [String])
-> MkOptDescr
     (InitFlags -> Flag Version)
     (Flag Version -> InitFlags -> InitFlags)
     InitFlags
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 package version: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
              (Version -> Flag Version
forall a. a -> Flag a
toFlag (Version -> Flag Version)
-> ParsecParser Version -> ParsecParser (Flag Version)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser Version
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m Version
parsec)
          )
          (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag Version -> Flag String) -> Flag Version -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Version -> String) -> Flag Version -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Version -> String
forall a. Pretty a => a -> String
prettyShow)
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag CabalSpecVersion)
-> (Flag CabalSpecVersion -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag CabalSpecVersion)
     (Flag CabalSpecVersion -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"cabal-version"]
      String
"Version of the Cabal specification."
      InitFlags -> Flag CabalSpecVersion
IT.cabalVersion
      (\Flag CabalSpecVersion
v InitFlags
flags -> InitFlags
flags{IT.cabalVersion = v})
      ( String
-> ReadE (Flag CabalSpecVersion)
-> (Flag CabalSpecVersion -> [String])
-> MkOptDescr
     (InitFlags -> Flag CabalSpecVersion)
     (Flag CabalSpecVersion -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
          String
"CABALSPECVERSION"
          ( (String -> String)
-> ParsecParser (Flag CabalSpecVersion)
-> ReadE (Flag CabalSpecVersion)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
              (String
"Cannot parse Cabal specification version: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
              ((SpecVersion -> Flag CabalSpecVersion)
-> ParsecParser SpecVersion -> ParsecParser (Flag CabalSpecVersion)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (CabalSpecVersion -> Flag CabalSpecVersion
forall a. a -> Flag a
toFlag (CabalSpecVersion -> Flag CabalSpecVersion)
-> (SpecVersion -> CabalSpecVersion)
-> SpecVersion
-> Flag CabalSpecVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SpecVersion -> CabalSpecVersion
getSpecVersion) ParsecParser SpecVersion
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m SpecVersion
parsec)
          )
          (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag CabalSpecVersion -> Flag String)
-> Flag CabalSpecVersion
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CabalSpecVersion -> String)
-> Flag CabalSpecVersion -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SpecVersion -> String
forall a. Pretty a => a -> String
prettyShow (SpecVersion -> String)
-> (CabalSpecVersion -> SpecVersion) -> CabalSpecVersion -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CabalSpecVersion -> SpecVersion
SpecVersion))
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag SpecLicense)
-> (Flag SpecLicense -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag SpecLicense)
     (Flag SpecLicense -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'l']
      [String
"license"]
      String
"Project license."
      InitFlags -> Flag SpecLicense
IT.license
      (\Flag SpecLicense
v InitFlags
flags -> InitFlags
flags{IT.license = v})
      ( String
-> ReadE (Flag SpecLicense)
-> (Flag SpecLicense -> [String])
-> MkOptDescr
     (InitFlags -> Flag SpecLicense)
     (Flag SpecLicense -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
          String
"LICENSE"
          ( (String -> String)
-> ParsecParser (Flag SpecLicense) -> ReadE (Flag SpecLicense)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
              (String
"Cannot parse license: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
              (SpecLicense -> Flag SpecLicense
forall a. a -> Flag a
toFlag (SpecLicense -> Flag SpecLicense)
-> ParsecParser SpecLicense -> ParsecParser (Flag SpecLicense)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser SpecLicense
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m SpecLicense
parsec)
          )
          (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag SpecLicense -> Flag String)
-> Flag SpecLicense
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SpecLicense -> String) -> Flag SpecLicense -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap SpecLicense -> String
forall a. Pretty a => a -> String
prettyShow)
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'a']
      [String
"author"]
      String
"Name of the project's author."
      InitFlags -> Flag String
IT.author
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.author = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"NAME")
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'e']
      [String
"email"]
      String
"Email address of the maintainer."
      InitFlags -> Flag String
IT.email
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.email = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"EMAIL")
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'u']
      [String
"homepage"]
      String
"Project homepage and/or repository."
      InitFlags -> Flag String
IT.homepage
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.homepage = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"URL")
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
's']
      [String
"synopsis"]
      String
"Short project synopsis."
      InitFlags -> Flag String
IT.synopsis
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.synopsis = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"TEXT")
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'c']
      [String
"category"]
      String
"Project category."
      InitFlags -> Flag String
IT.category
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.category = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"CATEGORY")
  , String
-> [String]
-> String
-> (InitFlags -> Flag [String])
-> (Flag [String] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'x']
      [String
"extra-source-file"]
      String
"Extra source file to be distributed with tarball."
      InitFlags -> Flag [String]
IT.extraSrc
      (\Flag [String]
v InitFlags
flags -> InitFlags
flags{IT.extraSrc = mergeListFlag (IT.extraSrc flags) v})
      ( String
-> (String -> Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg'
          String
"FILE"
          ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> (String -> [String]) -> String -> Flag [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: []))
          ([String] -> Flag [String] -> [String]
forall a. a -> Flag a -> a
fromFlagOrDefault [])
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag [String])
-> (Flag [String] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"extra-doc-file"]
      String
"Extra doc file to be distributed with tarball."
      InitFlags -> Flag [String]
IT.extraDoc
      (\Flag [String]
v InitFlags
flags -> InitFlags
flags{IT.extraDoc = mergeListFlag (IT.extraDoc flags) v})
      (String
-> (String -> Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"FILE" ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> (String -> [String]) -> String -> Flag [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [])) ([String] -> Flag [String] -> [String]
forall a. a -> Flag a -> a
fromFlagOrDefault []))
  , String
-> [String]
-> String
-> (InitFlags -> Flag PackageType)
-> (Flag PackageType -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag PackageType)
     (Flag PackageType -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"lib", String
"is-library"]
      String
"Build a library."
      InitFlags -> Flag PackageType
IT.packageType
      (\Flag PackageType
v InitFlags
flags -> InitFlags
flags{IT.packageType = v})
      (Flag PackageType
-> MkOptDescr
     (InitFlags -> Flag PackageType)
     (Flag PackageType -> InitFlags -> InitFlags)
     InitFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (PackageType -> Flag PackageType
forall a. a -> Flag a
Flag PackageType
IT.Library))
  , String
-> [String]
-> String
-> (InitFlags -> Flag PackageType)
-> (Flag PackageType -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag PackageType)
     (Flag PackageType -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"exe", String
"is-executable"]
      String
"Build an executable."
      InitFlags -> Flag PackageType
IT.packageType
      (\Flag PackageType
v InitFlags
flags -> InitFlags
flags{IT.packageType = v})
      (Flag PackageType
-> MkOptDescr
     (InitFlags -> Flag PackageType)
     (Flag PackageType -> InitFlags -> InitFlags)
     InitFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (PackageType -> Flag PackageType
forall a. a -> Flag a
Flag PackageType
IT.Executable))
  , String
-> [String]
-> String
-> (InitFlags -> Flag PackageType)
-> (Flag PackageType -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag PackageType)
     (Flag PackageType -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"libandexe", String
"is-libandexe"]
      String
"Build a library and an executable."
      InitFlags -> Flag PackageType
IT.packageType
      (\Flag PackageType
v InitFlags
flags -> InitFlags
flags{IT.packageType = v})
      (Flag PackageType
-> MkOptDescr
     (InitFlags -> Flag PackageType)
     (Flag PackageType -> InitFlags -> InitFlags)
     InitFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (PackageType -> Flag PackageType
forall a. a -> Flag a
Flag PackageType
IT.LibraryAndExecutable))
  , String
-> [String]
-> String
-> (InitFlags -> Flag Bool)
-> (Flag Bool -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"tests"]
      String
"Generate a test suite, standalone or for a library."
      InitFlags -> Flag Bool
IT.initializeTestSuite
      (\Flag Bool
v InitFlags
flags -> InitFlags
flags{IT.initializeTestSuite = v})
      MkOptDescr
  (InitFlags -> Flag Bool)
  (Flag Bool -> InitFlags -> InitFlags)
  InitFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
  , String
-> [String]
-> String
-> (InitFlags -> Flag [String])
-> (Flag [String] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"test-dir"]
      String
"Directory containing tests."
      InitFlags -> Flag [String]
IT.testDirs
      ( \Flag [String]
v InitFlags
flags ->
          InitFlags
flags{IT.testDirs = mergeListFlag (IT.testDirs flags) v}
      )
      ( String
-> (String -> Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg'
          String
"DIR"
          ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> (String -> [String]) -> String -> Flag [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: []))
          ([String] -> Flag [String] -> [String]
forall a. a -> Flag a -> a
fromFlagOrDefault [])
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag Bool)
-> (Flag Bool -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Bool)
     (Flag Bool -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"simple"]
      String
"Create a simple project with sensible defaults."
      InitFlags -> Flag Bool
IT.simpleProject
      (\Flag Bool
v InitFlags
flags -> InitFlags
flags{IT.simpleProject = v})
      MkOptDescr
  (InitFlags -> Flag Bool)
  (Flag Bool -> InitFlags -> InitFlags)
  InitFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"main-is"]
      String
"Specify the main module."
      InitFlags -> Flag String
IT.mainIs
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.mainIs = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"FILE")
  , String
-> [String]
-> String
-> (InitFlags -> Flag Language)
-> (Flag Language -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag Language)
     (Flag Language -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"language"]
      String
"Specify the default language."
      InitFlags -> Flag Language
IT.language
      (\Flag Language
v InitFlags
flags -> InitFlags
flags{IT.language = v})
      ( String
-> ReadE (Flag Language)
-> (Flag Language -> [String])
-> MkOptDescr
     (InitFlags -> Flag Language)
     (Flag Language -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
          String
"LANGUAGE"
          ( (String -> String)
-> ParsecParser (Flag Language) -> ReadE (Flag Language)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
              (String
"Cannot parse language: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
              (Language -> Flag Language
forall a. a -> Flag a
toFlag (Language -> Flag Language)
-> ParsecParser Language -> ParsecParser (Flag Language)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser Language
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m Language
parsec)
          )
          (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag Language -> Flag String) -> Flag Language -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Language -> String) -> Flag Language -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Language -> String
forall a. Pretty a => a -> String
prettyShow)
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag [ModuleName])
-> (Flag [ModuleName] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [ModuleName])
     (Flag [ModuleName] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'o']
      [String
"expose-module"]
      String
"Export a module from the package."
      InitFlags -> Flag [ModuleName]
IT.exposedModules
      ( \Flag [ModuleName]
v InitFlags
flags ->
          InitFlags
flags
            { IT.exposedModules =
                mergeListFlag (IT.exposedModules flags) v
            }
      )
      ( String
-> ReadE (Flag [ModuleName])
-> (Flag [ModuleName] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [ModuleName])
     (Flag [ModuleName] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
          String
"MODULE"
          ( (String -> String)
-> ParsecParser (Flag [ModuleName]) -> ReadE (Flag [ModuleName])
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
              (String
"Cannot parse module name: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
              ([ModuleName] -> Flag [ModuleName]
forall a. a -> Flag a
Flag ([ModuleName] -> Flag [ModuleName])
-> (ModuleName -> [ModuleName]) -> ModuleName -> Flag [ModuleName]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModuleName -> [ModuleName] -> [ModuleName]
forall a. a -> [a] -> [a]
: []) (ModuleName -> Flag [ModuleName])
-> ParsecParser ModuleName -> ParsecParser (Flag [ModuleName])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecParser ModuleName
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m ModuleName
parsec)
          )
          ([String]
-> ([ModuleName] -> [String]) -> Flag [ModuleName] -> [String]
forall b a. b -> (a -> b) -> Flag a -> b
flagElim [] ((ModuleName -> String) -> [ModuleName] -> [String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ModuleName -> String
forall a. Pretty a => a -> String
prettyShow))
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag [Extension])
-> (Flag [Extension] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [Extension])
     (Flag [Extension] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"extension"]
      String
"Use a LANGUAGE extension (in the other-extensions field)."
      InitFlags -> Flag [Extension]
IT.otherExts
      ( \Flag [Extension]
v InitFlags
flags ->
          InitFlags
flags
            { IT.otherExts =
                mergeListFlag (IT.otherExts flags) v
            }
      )
      ( String
-> ReadE (Flag [Extension])
-> (Flag [Extension] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [Extension])
     (Flag [Extension] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
          String
"EXTENSION"
          ( (String -> String)
-> ParsecParser (Flag [Extension]) -> ReadE (Flag [Extension])
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
              (String
"Cannot parse extension: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
              ([Extension] -> Flag [Extension]
forall a. a -> Flag a
Flag ([Extension] -> Flag [Extension])
-> (Extension -> [Extension]) -> Extension -> Flag [Extension]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Extension -> [Extension] -> [Extension]
forall a. a -> [a] -> [a]
: []) (Extension -> Flag [Extension])
-> ParsecParser Extension -> ParsecParser (Flag [Extension])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecParser Extension
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m Extension
parsec)
          )
          ([String]
-> ([Extension] -> [String]) -> Flag [Extension] -> [String]
forall b a. b -> (a -> b) -> Flag a -> b
flagElim [] ((Extension -> String) -> [Extension] -> [String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Extension -> String
forall a. Pretty a => a -> String
prettyShow))
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag [Dependency])
-> (Flag [Dependency] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [Dependency])
     (Flag [Dependency] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      [Char
'd']
      [String
"dependency"]
      String
"Package dependencies. Permits comma separated list of dependencies."
      InitFlags -> Flag [Dependency]
IT.dependencies
      ( \Flag [Dependency]
v InitFlags
flags ->
          InitFlags
flags
            { IT.dependencies =
                mergeListFlag (IT.dependencies flags) v
            }
      )
      ( String
-> ReadE (Flag [Dependency])
-> (Flag [Dependency] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [Dependency])
     (Flag [Dependency] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
          String
"DEPENDENCIES"
          (([Dependency] -> Flag [Dependency])
-> ReadE [Dependency] -> ReadE (Flag [Dependency])
forall a b. (a -> b) -> ReadE a -> ReadE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Dependency] -> Flag [Dependency]
forall a. a -> Flag a
Flag ReadE [Dependency]
dependenciesReadE)
          ((Dependency -> String) -> [Dependency] -> [String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Dependency -> String
forall a. Pretty a => a -> String
prettyShow ([Dependency] -> [String])
-> (Flag [Dependency] -> [Dependency])
-> Flag [Dependency]
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Dependency] -> Flag [Dependency] -> [Dependency]
forall a. a -> Flag a -> a
fromFlagOrDefault [])
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag [String])
-> (Flag [String] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"application-dir"]
      String
"Directory containing package application executable."
      InitFlags -> Flag [String]
IT.applicationDirs
      ( \Flag [String]
v InitFlags
flags ->
          InitFlags
flags
            { IT.applicationDirs =
                mergeListFlag (IT.applicationDirs flags) v
            }
      )
      ( String
-> (String -> Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg'
          String
"DIR"
          ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> (String -> [String]) -> String -> Flag [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: []))
          ([String] -> Flag [String] -> [String]
forall a. a -> Flag a -> a
fromFlagOrDefault [])
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag [String])
-> (Flag [String] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"source-dir", String
"sourcedir"]
      String
"Directory containing package library source."
      InitFlags -> Flag [String]
IT.sourceDirs
      ( \Flag [String]
v InitFlags
flags ->
          InitFlags
flags
            { IT.sourceDirs =
                mergeListFlag (IT.sourceDirs flags) v
            }
      )
      ( String
-> (String -> Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg'
          String
"DIR"
          ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> (String -> [String]) -> String -> Flag [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: []))
          ([String] -> Flag [String] -> [String]
forall a. a -> Flag a -> a
fromFlagOrDefault [])
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag [String])
-> (Flag [String] -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
      []
      [String
"build-tool"]
      String
"Required external build tool."
      InitFlags -> Flag [String]
IT.buildTools
      ( \Flag [String]
v InitFlags
flags ->
          InitFlags
flags
            { IT.buildTools =
                mergeListFlag (IT.buildTools flags) v
            }
      )
      ( String
-> (String -> Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (InitFlags -> Flag [String])
     (Flag [String] -> InitFlags -> InitFlags)
     InitFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg'
          String
"TOOL"
          ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> (String -> [String]) -> String -> Flag [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: []))
          ([String] -> Flag [String] -> [String]
forall a. a -> Flag a -> a
fromFlagOrDefault [])
      )
  , String
-> [String]
-> String
-> (InitFlags -> Flag String)
-> (Flag String -> InitFlags -> InitFlags)
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
-> OptionField InitFlags
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. For 'init', this flag is used \
      \to set the bounds inferred for the 'base' package."
      InitFlags -> Flag String
IT.initHcPath
      (\Flag String
v InitFlags
flags -> InitFlags
flags{IT.initHcPath = v})
      (String
-> MkOptDescr
     (InitFlags -> Flag String)
     (Flag String -> InitFlags -> InitFlags)
     InitFlags
forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
"PATH")
  , (InitFlags -> Flag Verbosity)
-> (Flag Verbosity -> InitFlags -> InitFlags)
-> OptionField InitFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity InitFlags -> Flag Verbosity
IT.initVerbosity (\Flag Verbosity
v InitFlags
flags -> InitFlags
flags{IT.initVerbosity = v})
  ]
  where
    dependenciesReadE :: ReadE [Dependency]
    dependenciesReadE :: ReadE [Dependency]
dependenciesReadE =
      (String -> String)
-> ParsecParser [Dependency] -> ReadE [Dependency]
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
        (String
"Cannot parse dependencies: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
        (ParsecParser Dependency -> ParsecParser [Dependency]
forall (m :: * -> *) a. CabalParsing m => m a -> m [a]
parsecCommaList ParsecParser Dependency
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m Dependency
parsec)

-- ------------------------------------------------------------

-- * Copy and Register

-- ------------------------------------------------------------

copyCommand :: CommandUI CopyFlags
copyCommand :: CommandUI CopyFlags
copyCommand =
  CommandUI CopyFlags
Cabal.copyCommand
    { commandNotes = Just $ \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-copy           "
          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-copy foo       "
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    A component (i.e. lib, exe, test suite)"
    , commandUsage =
        usageAlternatives "v1-copy" $
          [ "[FLAGS]"
          , "COMPONENTS [FLAGS]"
          ]
    }

registerCommand :: CommandUI RegisterFlags
registerCommand :: CommandUI RegisterFlags
registerCommand =
  CommandUI RegisterFlags
Cabal.registerCommand
    { 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-register [FLAGS]\n"
    }

-- ------------------------------------------------------------

-- * ActAsSetup flags

-- ------------------------------------------------------------

data ActAsSetupFlags = ActAsSetupFlags
  { ActAsSetupFlags -> Flag BuildType
actAsSetupBuildType :: Flag BuildType
  }
  deriving ((forall x. ActAsSetupFlags -> Rep ActAsSetupFlags x)
-> (forall x. Rep ActAsSetupFlags x -> ActAsSetupFlags)
-> Generic ActAsSetupFlags
forall x. Rep ActAsSetupFlags x -> ActAsSetupFlags
forall x. ActAsSetupFlags -> Rep ActAsSetupFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ActAsSetupFlags -> Rep ActAsSetupFlags x
from :: forall x. ActAsSetupFlags -> Rep ActAsSetupFlags x
$cto :: forall x. Rep ActAsSetupFlags x -> ActAsSetupFlags
to :: forall x. Rep ActAsSetupFlags x -> ActAsSetupFlags
Generic)

defaultActAsSetupFlags :: ActAsSetupFlags
defaultActAsSetupFlags :: ActAsSetupFlags
defaultActAsSetupFlags =
  ActAsSetupFlags
    { actAsSetupBuildType :: Flag BuildType
actAsSetupBuildType = BuildType -> Flag BuildType
forall a. a -> Flag a
toFlag BuildType
Simple
    }

actAsSetupCommand :: CommandUI ActAsSetupFlags
actAsSetupCommand :: CommandUI ActAsSetupFlags
actAsSetupCommand =
  CommandUI
    { commandName :: String
commandName = String
"act-as-setup"
    , commandSynopsis :: String
commandSynopsis = String
"Run as-if this was a Setup.hs"
    , 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
pname ->
        String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" act-as-setup\n"
    , commandDefaultFlags :: ActAsSetupFlags
commandDefaultFlags = ActAsSetupFlags
defaultActAsSetupFlags
    , commandOptions :: ShowOrParseArgs -> [OptionField ActAsSetupFlags]
commandOptions = \ShowOrParseArgs
_ ->
        [ String
-> [String]
-> String
-> (ActAsSetupFlags -> Flag BuildType)
-> (Flag BuildType -> ActAsSetupFlags -> ActAsSetupFlags)
-> MkOptDescr
     (ActAsSetupFlags -> Flag BuildType)
     (Flag BuildType -> ActAsSetupFlags -> ActAsSetupFlags)
     ActAsSetupFlags
-> OptionField ActAsSetupFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            String
""
            [String
"build-type"]
            String
"Use the given build type."
            ActAsSetupFlags -> Flag BuildType
actAsSetupBuildType
            (\Flag BuildType
v ActAsSetupFlags
flags -> ActAsSetupFlags
flags{actAsSetupBuildType = v})
            ( String
-> ReadE (Flag BuildType)
-> (Flag BuildType -> [String])
-> MkOptDescr
     (ActAsSetupFlags -> Flag BuildType)
     (Flag BuildType -> ActAsSetupFlags -> ActAsSetupFlags)
     ActAsSetupFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
                String
"BUILD-TYPE"
                ( (String -> String)
-> ParsecParser (Flag BuildType) -> ReadE (Flag BuildType)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
                    (String
"Cannot parse build type: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
                    ((BuildType -> Flag BuildType)
-> ParsecParser BuildType -> ParsecParser (Flag BuildType)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BuildType -> Flag BuildType
forall a. a -> Flag a
toFlag ParsecParser BuildType
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m BuildType
parsec)
                )
                ((BuildType -> String) -> [BuildType] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map BuildType -> String
forall a. Pretty a => a -> String
prettyShow ([BuildType] -> [String])
-> (Flag BuildType -> [BuildType]) -> Flag BuildType -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag BuildType -> [BuildType]
forall a. Flag a -> [a]
flagToList)
            )
        ]
    }

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

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

-- ------------------------------------------------------------

-- * UserConfig flags

-- ------------------------------------------------------------

data UserConfigFlags = UserConfigFlags
  { UserConfigFlags -> Flag Verbosity
userConfigVerbosity :: Flag Verbosity
  , UserConfigFlags -> Flag Bool
userConfigForce :: Flag Bool
  , UserConfigFlags -> Flag [String]
userConfigAppendLines :: Flag [String]
  }
  deriving ((forall x. UserConfigFlags -> Rep UserConfigFlags x)
-> (forall x. Rep UserConfigFlags x -> UserConfigFlags)
-> Generic UserConfigFlags
forall x. Rep UserConfigFlags x -> UserConfigFlags
forall x. UserConfigFlags -> Rep UserConfigFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UserConfigFlags -> Rep UserConfigFlags x
from :: forall x. UserConfigFlags -> Rep UserConfigFlags x
$cto :: forall x. Rep UserConfigFlags x -> UserConfigFlags
to :: forall x. Rep UserConfigFlags x -> UserConfigFlags
Generic)

instance Monoid UserConfigFlags where
  mempty :: UserConfigFlags
mempty =
    UserConfigFlags
      { userConfigVerbosity :: Flag Verbosity
userConfigVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
toFlag Verbosity
normal
      , userConfigForce :: Flag Bool
userConfigForce = Bool -> Flag Bool
forall a. a -> Flag a
toFlag Bool
False
      , userConfigAppendLines :: Flag [String]
userConfigAppendLines = [String] -> Flag [String]
forall a. a -> Flag a
toFlag []
      }
  mappend :: UserConfigFlags -> UserConfigFlags -> UserConfigFlags
mappend = UserConfigFlags -> UserConfigFlags -> UserConfigFlags
forall a. Semigroup a => a -> a -> a
(<>)

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

userConfigCommand :: CommandUI UserConfigFlags
userConfigCommand :: CommandUI UserConfigFlags
userConfigCommand =
  CommandUI
    { commandName :: String
commandName = String
"user-config"
    , commandSynopsis :: String
commandSynopsis = String
"Display and update the user's global cabal configuration."
    , 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
"When upgrading cabal, the set of configuration keys and their default"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" values may change. This command provides means to merge the existing"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" config in ~/.config/cabal/config"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" (i.e. all bindings that are actually defined and not commented out)"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" and the default config of the new version.\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"init: Creates a new config file at either ~/.config/cabal/config or as"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" specified by --config-file, if given. An existing file won't be "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" overwritten unless -f or --force is given.\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"diff: Shows a pseudo-diff of the user's ~/.config/cabal/config file and"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" the default configuration that would be created by cabal if the"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" config file did not exist.\n"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"update: Applies the pseudo-diff to the configuration that would be"
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" created by default, and write the result back to ~/.config/cabal/config."
    , commandNotes :: Maybe (String -> String)
commandNotes = Maybe (String -> String)
forall a. Maybe a
Nothing
    , commandUsage :: String -> String
commandUsage = String -> [String] -> String -> String
usageAlternatives String
"user-config" [String
"init", String
"diff", String
"update"]
    , commandDefaultFlags :: UserConfigFlags
commandDefaultFlags = UserConfigFlags
forall a. Monoid a => a
mempty
    , commandOptions :: ShowOrParseArgs -> [OptionField UserConfigFlags]
commandOptions = \ShowOrParseArgs
_ ->
        [ (UserConfigFlags -> Flag Verbosity)
-> (Flag Verbosity -> UserConfigFlags -> UserConfigFlags)
-> OptionField UserConfigFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity UserConfigFlags -> Flag Verbosity
userConfigVerbosity (\Flag Verbosity
v UserConfigFlags
flags -> UserConfigFlags
flags{userConfigVerbosity = v})
        , String
-> [String]
-> String
-> (UserConfigFlags -> Flag Bool)
-> (Flag Bool -> UserConfigFlags -> UserConfigFlags)
-> MkOptDescr
     (UserConfigFlags -> Flag Bool)
     (Flag Bool -> UserConfigFlags -> UserConfigFlags)
     UserConfigFlags
-> OptionField UserConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
'f']
            [String
"force"]
            String
"Overwrite the config file if it already exists."
            UserConfigFlags -> Flag Bool
userConfigForce
            (\Flag Bool
v UserConfigFlags
flags -> UserConfigFlags
flags{userConfigForce = v})
            MkOptDescr
  (UserConfigFlags -> Flag Bool)
  (Flag Bool -> UserConfigFlags -> UserConfigFlags)
  UserConfigFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
        , String
-> [String]
-> String
-> (UserConfigFlags -> Flag [String])
-> (Flag [String] -> UserConfigFlags -> UserConfigFlags)
-> MkOptDescr
     (UserConfigFlags -> Flag [String])
     (Flag [String] -> UserConfigFlags -> UserConfigFlags)
     UserConfigFlags
-> OptionField UserConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
            [Char
'a']
            [String
"augment"]
            String
"Additional setting to augment the config file (replacing a previous setting if it existed)."
            UserConfigFlags -> Flag [String]
userConfigAppendLines
            ( \Flag [String]
v UserConfigFlags
flags ->
                UserConfigFlags
flags
                  { userConfigAppendLines =
                      Flag $ concat (flagToList (userConfigAppendLines flags) ++ flagToList v)
                  }
            )
            (String
-> (String -> Flag [String])
-> (Flag [String] -> [String])
-> MkOptDescr
     (UserConfigFlags -> Flag [String])
     (Flag [String] -> UserConfigFlags -> UserConfigFlags)
     UserConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"CONFIGLINE" ([String] -> Flag [String]
forall a. a -> Flag a
Flag ([String] -> Flag [String])
-> (String -> [String]) -> String -> Flag [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [])) ([String] -> Maybe [String] -> [String]
forall a. a -> Maybe a -> a
fromMaybe [] (Maybe [String] -> [String])
-> (Flag [String] -> Maybe [String]) -> Flag [String] -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag [String] -> Maybe [String]
forall a. Flag a -> Maybe a
flagToMaybe))
        ]
    }

-- ------------------------------------------------------------

-- * GetOpt Utils

-- ------------------------------------------------------------

reqArgFlag
  :: ArgPlaceHolder
  -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag :: forall b.
String -> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
reqArgFlag String
ad = String
-> ReadE (Flag String)
-> (Flag String -> [String])
-> MkOptDescr (b -> Flag String) (Flag String -> b -> b) b
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
ad ((String -> Flag String) -> ReadE (Flag String)
forall a. (String -> a) -> ReadE a
succeedReadE String -> Flag String
forall a. a -> Flag a
Flag) Flag String -> [String]
forall a. Flag a -> [a]
flagToList

liftOptions
  :: (b -> a)
  -> (a -> b -> b)
  -> [OptionField a]
  -> [OptionField b]
liftOptions :: forall b a.
(b -> a) -> (a -> b -> b) -> [OptionField a] -> [OptionField b]
liftOptions b -> a
get a -> b -> b
set = (OptionField a -> OptionField b)
-> [OptionField a] -> [OptionField b]
forall a b. (a -> b) -> [a] -> [b]
map ((b -> a) -> (a -> b -> b) -> OptionField a -> OptionField b
forall b a.
(b -> a) -> (a -> b -> b) -> OptionField a -> OptionField b
liftOption b -> a
get a -> b -> b
set)

yesNoOpt :: ShowOrParseArgs -> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt :: forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
ShowArgs String
sf [String]
lf = MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg String
sf [String]
lf
yesNoOpt ShowOrParseArgs
_ String
sf [String]
lf = (Flag Bool -> Maybe Bool)
-> (Bool -> Flag Bool)
-> OptFlags
-> OptFlags
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
forall b a.
(b -> Maybe Bool)
-> (Bool -> b)
-> OptFlags
-> OptFlags
-> MkOptDescr (a -> b) (b -> a -> a) a
Command.boolOpt' Flag Bool -> Maybe Bool
forall a. Flag a -> Maybe a
flagToMaybe Bool -> Flag Bool
forall a. a -> Flag a
Flag (String
sf, [String]
lf) ([], (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
"no-" String -> String -> String
forall a. [a] -> [a] -> [a]
++) [String]
lf) String
sf [String]
lf

optionSolver
  :: (flags -> Flag PreSolver)
  -> (Flag PreSolver -> flags -> flags)
  -> OptionField flags
optionSolver :: forall flags.
(flags -> Flag PreSolver)
-> (Flag PreSolver -> flags -> flags) -> OptionField flags
optionSolver flags -> Flag PreSolver
get Flag PreSolver -> flags -> flags
set =
  String
-> [String]
-> String
-> (flags -> Flag PreSolver)
-> (Flag PreSolver -> flags -> flags)
-> MkOptDescr
     (flags -> Flag PreSolver) (Flag PreSolver -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
    []
    [String
"solver"]
    (String
"Select dependency solver to use (default: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ PreSolver -> String
forall a. Pretty a => a -> String
prettyShow PreSolver
defaultSolver String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"). Choices: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
allSolvers String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
".")
    flags -> Flag PreSolver
get
    Flag PreSolver -> flags -> flags
set
    ( String
-> ReadE (Flag PreSolver)
-> (Flag PreSolver -> [String])
-> MkOptDescr
     (flags -> Flag PreSolver) (Flag PreSolver -> flags -> flags) flags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
        String
"SOLVER"
        ( (String -> String)
-> ParsecParser (Flag PreSolver) -> ReadE (Flag PreSolver)
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
"solver must be one of: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
allSolvers)
            (PreSolver -> Flag PreSolver
forall a. a -> Flag a
toFlag (PreSolver -> Flag PreSolver)
-> ParsecParser PreSolver -> ParsecParser (Flag PreSolver)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser PreSolver
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m PreSolver
parsec)
        )
        (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag PreSolver -> Flag String) -> Flag PreSolver -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PreSolver -> String) -> Flag PreSolver -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PreSolver -> String
forall a. Pretty a => a -> String
prettyShow)
    )

optionSolverFlags
  :: 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 PreferOldest)
  -> (Flag PreferOldest -> 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 :: 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 PreferOldest)
-> (Flag PreferOldest -> 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
  flags -> Flag Int
getmbj
  Flag Int -> flags -> flags
setmbj
  flags -> Flag ReorderGoals
getrg
  Flag ReorderGoals -> flags -> flags
setrg
  flags -> Flag CountConflicts
getcc
  Flag CountConflicts -> flags -> flags
setcc
  flags -> Flag FineGrainedConflicts
getfgc
  Flag FineGrainedConflicts -> flags -> flags
setfgc
  flags -> Flag MinimizeConflictSet
getmc
  Flag MinimizeConflictSet -> flags -> flags
setmc
  flags -> Flag IndependentGoals
getig
  Flag IndependentGoals -> flags -> flags
setig
  flags -> Flag PreferOldest
getpo
  Flag PreferOldest -> flags -> flags
setpo
  flags -> Flag ShadowPkgs
getsip
  Flag ShadowPkgs -> flags -> flags
setsip
  flags -> Flag StrongFlags
getstrfl
  Flag StrongFlags -> flags -> flags
setstrfl
  flags -> Flag AllowBootLibInstalls
getib
  Flag AllowBootLibInstalls -> flags -> flags
setib
  flags -> Flag OnlyConstrained
getoc
  Flag OnlyConstrained -> flags -> flags
setoc =
    [ String
-> [String]
-> String
-> (flags -> Flag Int)
-> (Flag Int -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Int) (Flag Int -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"max-backjumps"]
        (String
"Maximum number of backjumps allowed while solving (default: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
defaultMaxBackjumps String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"). Use a negative number to enable unlimited backtracking. Use 0 to disable backtracking completely.")
        flags -> Flag Int
getmbj
        Flag Int -> flags -> flags
setmbj
        ( String
-> ReadE (Flag Int)
-> (Flag Int -> [String])
-> MkOptDescr
     (flags -> Flag Int) (Flag Int -> flags -> flags) flags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
            String
"NUM"
            ((String -> String) -> ParsecParser (Flag Int) -> ReadE (Flag Int)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String
"Cannot parse number: " String -> String -> String
forall a. [a] -> [a] -> [a]
++) ((Int -> Flag Int) -> ParsecParser Int -> ParsecParser (Flag Int)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Flag Int
forall a. a -> Flag a
toFlag ParsecParser Int
forall (m :: * -> *) a. (CharParsing m, Integral a) => m a
P.signedIntegral))
            ((Int -> String) -> [Int] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Int -> String
forall a. Show a => a -> String
show ([Int] -> [String]) -> (Flag Int -> [Int]) -> Flag Int -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag Int -> [Int]
forall a. Flag a -> [a]
flagToList)
        )
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"reorder-goals"]
        String
"Try to reorder goals according to certain heuristics. Slows things down on average, but may make backtracking faster for some packages."
        ((ReorderGoals -> Bool) -> Flag ReorderGoals -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ReorderGoals -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag ReorderGoals -> Flag Bool)
-> (flags -> Flag ReorderGoals) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag ReorderGoals
getrg)
        (Flag ReorderGoals -> flags -> flags
setrg (Flag ReorderGoals -> flags -> flags)
-> (Flag Bool -> Flag ReorderGoals) -> Flag Bool -> flags -> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ReorderGoals) -> Flag Bool -> Flag ReorderGoals
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> ReorderGoals
ReorderGoals)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"count-conflicts"]
        String
"Try to speed up solving by preferring goals that are involved in a lot of conflicts (default)."
        ((CountConflicts -> Bool) -> Flag CountConflicts -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CountConflicts -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag CountConflicts -> Flag Bool)
-> (flags -> Flag CountConflicts) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag CountConflicts
getcc)
        (Flag CountConflicts -> flags -> flags
setcc (Flag CountConflicts -> flags -> flags)
-> (Flag Bool -> Flag CountConflicts)
-> Flag Bool
-> flags
-> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> CountConflicts) -> Flag Bool -> Flag CountConflicts
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> CountConflicts
CountConflicts)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"fine-grained-conflicts"]
        String
"Skip a version of a package if it does not resolve the conflicts encountered in the last version, as a solver optimization (default)."
        ((FineGrainedConflicts -> Bool)
-> Flag FineGrainedConflicts -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap FineGrainedConflicts -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag FineGrainedConflicts -> Flag Bool)
-> (flags -> Flag FineGrainedConflicts) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag FineGrainedConflicts
getfgc)
        (Flag FineGrainedConflicts -> flags -> flags
setfgc (Flag FineGrainedConflicts -> flags -> flags)
-> (Flag Bool -> Flag FineGrainedConflicts)
-> Flag Bool
-> flags
-> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> FineGrainedConflicts)
-> Flag Bool -> Flag FineGrainedConflicts
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> FineGrainedConflicts
FineGrainedConflicts)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"minimize-conflict-set"]
        ( String
"When there is no solution, try to improve the error message by finding "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"a minimal conflict set (default: false). May increase run time "
            String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"significantly."
        )
        ((MinimizeConflictSet -> Bool)
-> Flag MinimizeConflictSet -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MinimizeConflictSet -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag MinimizeConflictSet -> Flag Bool)
-> (flags -> Flag MinimizeConflictSet) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag MinimizeConflictSet
getmc)
        (Flag MinimizeConflictSet -> flags -> flags
setmc (Flag MinimizeConflictSet -> flags -> flags)
-> (Flag Bool -> Flag MinimizeConflictSet)
-> Flag Bool
-> flags
-> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> MinimizeConflictSet)
-> Flag Bool -> Flag MinimizeConflictSet
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> MinimizeConflictSet
MinimizeConflictSet)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"independent-goals"]
        String
"Treat several goals on the command line as independent. If several goals depend on the same package, different versions can be chosen."
        ((IndependentGoals -> Bool) -> Flag IndependentGoals -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IndependentGoals -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag IndependentGoals -> Flag Bool)
-> (flags -> Flag IndependentGoals) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag IndependentGoals
getig)
        (Flag IndependentGoals -> flags -> flags
setig (Flag IndependentGoals -> flags -> flags)
-> (Flag Bool -> Flag IndependentGoals)
-> Flag Bool
-> flags
-> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> IndependentGoals) -> Flag Bool -> Flag IndependentGoals
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> IndependentGoals
IndependentGoals)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"prefer-oldest"]
        String
"Prefer the oldest (instead of the latest) versions of packages available. Useful to determine lower bounds in the build-depends section."
        ((PreferOldest -> Bool) -> Flag PreferOldest -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PreferOldest -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag PreferOldest -> Flag Bool)
-> (flags -> Flag PreferOldest) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag PreferOldest
getpo)
        (Flag PreferOldest -> flags -> flags
setpo (Flag PreferOldest -> flags -> flags)
-> (Flag Bool -> Flag PreferOldest) -> Flag Bool -> flags -> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> PreferOldest) -> Flag Bool -> Flag PreferOldest
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> PreferOldest
PreferOldest)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"shadow-installed-packages"]
        String
"If multiple package instances of the same version are installed, treat all but one as shadowed."
        ((ShadowPkgs -> Bool) -> Flag ShadowPkgs -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShadowPkgs -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag ShadowPkgs -> Flag Bool)
-> (flags -> Flag ShadowPkgs) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag ShadowPkgs
getsip)
        (Flag ShadowPkgs -> flags -> flags
setsip (Flag ShadowPkgs -> flags -> flags)
-> (Flag Bool -> Flag ShadowPkgs) -> Flag Bool -> flags -> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShadowPkgs) -> Flag Bool -> Flag ShadowPkgs
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> ShadowPkgs
ShadowPkgs)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"strong-flags"]
        String
"Do not defer flag choices (this used to be the default in cabal-install <= 1.20)."
        ((StrongFlags -> Bool) -> Flag StrongFlags -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap StrongFlags -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag StrongFlags -> Flag Bool)
-> (flags -> Flag StrongFlags) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag StrongFlags
getstrfl)
        (Flag StrongFlags -> flags -> flags
setstrfl (Flag StrongFlags -> flags -> flags)
-> (Flag Bool -> Flag StrongFlags) -> Flag Bool -> flags -> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> StrongFlags) -> Flag Bool -> Flag StrongFlags
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> StrongFlags
StrongFlags)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag Bool)
-> (Flag Bool -> flags -> flags)
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"allow-boot-library-installs"]
        String
"Allow cabal to install base, ghc-prim, integer-simple, integer-gmp, and template-haskell."
        ((AllowBootLibInstalls -> Bool)
-> Flag AllowBootLibInstalls -> Flag Bool
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AllowBootLibInstalls -> Bool
forall a. BooleanFlag a => a -> Bool
asBool (Flag AllowBootLibInstalls -> Flag Bool)
-> (flags -> Flag AllowBootLibInstalls) -> flags -> Flag Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. flags -> Flag AllowBootLibInstalls
getib)
        (Flag AllowBootLibInstalls -> flags -> flags
setib (Flag AllowBootLibInstalls -> flags -> flags)
-> (Flag Bool -> Flag AllowBootLibInstalls)
-> Flag Bool
-> flags
-> flags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> AllowBootLibInstalls)
-> Flag Bool -> Flag AllowBootLibInstalls
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> AllowBootLibInstalls
AllowBootLibInstalls)
        (ShowOrParseArgs
-> MkOptDescr
     (flags -> Flag Bool) (Flag Bool -> flags -> flags) flags
forall b.
ShowOrParseArgs
-> MkOptDescr (b -> Flag Bool) (Flag Bool -> b -> b) b
yesNoOpt ShowOrParseArgs
showOrParseArgs)
    , String
-> [String]
-> String
-> (flags -> Flag OnlyConstrained)
-> (Flag OnlyConstrained -> flags -> flags)
-> MkOptDescr
     (flags -> Flag OnlyConstrained)
     (Flag OnlyConstrained -> flags -> flags)
     flags
-> OptionField flags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option
        []
        [String
"reject-unconstrained-dependencies"]
        String
"Require these packages to have constraints on them if they are to be selected (default: none)."
        flags -> Flag OnlyConstrained
getoc
        Flag OnlyConstrained -> flags -> flags
setoc
        ( String
-> ReadE (Flag OnlyConstrained)
-> (Flag OnlyConstrained -> [String])
-> MkOptDescr
     (flags -> Flag OnlyConstrained)
     (Flag OnlyConstrained -> flags -> flags)
     flags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg
            String
"none|all"
            ( (String -> String)
-> ParsecParser (Flag OnlyConstrained)
-> ReadE (Flag OnlyConstrained)
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE
                (String -> String -> String
forall a b. a -> b -> a
const String
"reject-unconstrained-dependencies must be 'none' or 'all'")
                (OnlyConstrained -> Flag OnlyConstrained
forall a. a -> Flag a
toFlag (OnlyConstrained -> Flag OnlyConstrained)
-> ParsecParser OnlyConstrained
-> ParsecParser (Flag OnlyConstrained)
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser OnlyConstrained
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m OnlyConstrained
parsec)
            )
            (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag OnlyConstrained -> Flag String)
-> Flag OnlyConstrained
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (OnlyConstrained -> String) -> Flag OnlyConstrained -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap OnlyConstrained -> String
forall a. Pretty a => a -> String
prettyShow)
        )
    ]

usagePackages :: String -> String -> String
usagePackages :: String -> String -> String
usagePackages String
name String
pname =
  String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" [PACKAGES]\n"

usageFlags :: String -> String -> String
usageFlags :: String -> String -> String
usageFlags String
name String
pname =
  String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" [FLAGS]\n"

-- ------------------------------------------------------------

-- * Repo helpers

-- ------------------------------------------------------------

showRemoteRepo :: RemoteRepo -> String
showRemoteRepo :: RemoteRepo -> String
showRemoteRepo = RemoteRepo -> String
forall a. Pretty a => a -> String
prettyShow

readRemoteRepo :: String -> Maybe RemoteRepo
readRemoteRepo :: String -> Maybe RemoteRepo
readRemoteRepo = String -> Maybe RemoteRepo
forall a. Parsec a => String -> Maybe a
simpleParsec

showLocalRepo :: LocalRepo -> String
showLocalRepo :: LocalRepo -> String
showLocalRepo = LocalRepo -> String
forall a. Pretty a => a -> String
prettyShow

readLocalRepo :: String -> Maybe LocalRepo
readLocalRepo :: String -> Maybe LocalRepo
readLocalRepo = String -> Maybe LocalRepo
forall a. Parsec a => String -> Maybe a
simpleParsec

-- ------------------------------------------------------------

-- * Helpers for Documentation

-- ------------------------------------------------------------

relevantConfigValuesText :: [String] -> String
relevantConfigValuesText :: [String] -> String
relevantConfigValuesText [String]
vs =
  String
"Relevant global configuration keys:\n"
    String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
v String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n" | String
v <- [String]
vs]