Distribution.Client.Config

cabal-install-3.12.1.0: The command-line interface for Cabal and Hackage.

Copyright | (c) David Himmelstrup 2005
License | BSD-like
Maintainer | lemmih@gmail.com
Stability | provisional
Portability | portable
Safe Haskell | None
Language | Haskell2010

Distribution.Client.Config

Description

Utilities for handling saved state such as known packages, known servers and downloaded packages.

Synopsis

- data SavedConfig = SavedConfig {
  - savedGlobalFlags :: GlobalFlags
  - savedInitFlags :: InitFlags
  - savedInstallFlags :: InstallFlags
  - savedClientInstallFlags :: ClientInstallFlags
  - savedConfigureFlags :: ConfigFlags
  - savedConfigureExFlags :: ConfigExFlags
  - savedUserInstallDirs :: InstallDirs (Flag PathTemplate)
  - savedGlobalInstallDirs :: InstallDirs (Flag PathTemplate)
  - savedUploadFlags :: UploadFlags
  - savedReportFlags :: ReportFlags
  - savedHaddockFlags :: HaddockFlags
  - savedTestFlags :: TestFlags
  - savedBenchmarkFlags :: BenchmarkFlags
  - savedProjectFlags :: ProjectFlags
  - savedReplMulti :: Flag Bool
  }
- loadConfig :: Verbosity -> Flag FilePath -> IO SavedConfig
- getConfigFilePath :: Flag FilePath -> IO FilePath
- showConfig :: SavedConfig -> String
- showConfigWithComments :: SavedConfig -> SavedConfig -> String
- parseConfig :: ConstraintSource -> SavedConfig -> ByteString -> ParseResult SavedConfig
- defaultConfigFile :: IO FilePath
- defaultCacheDir :: IO FilePath
- defaultCacheHome :: IO FilePath
- defaultScriptBuildsDir :: IO FilePath
- defaultStoreDir :: IO FilePath
- defaultCompiler :: CompilerFlavor
- defaultInstallPath :: IO FilePath
- defaultLogsDir :: IO FilePath
- defaultReportsDir :: IO FilePath
- defaultUserInstall :: Bool
- baseSavedConfig :: IO SavedConfig
- commentSavedConfig :: IO SavedConfig
- initialSavedConfig :: IO SavedConfig
- configFieldDescriptions :: ConstraintSource -> [FieldDescr SavedConfig]
- haddockFlagsFields :: [FieldDescr HaddockFlags]
- installDirsFields :: [FieldDescr (InstallDirs (Flag PathTemplate))]
- withProgramsFields :: [FieldDescr [(String, FilePath)]]
- withProgramOptionsFields :: [FieldDescr [(String, [String])]]
- userConfigDiff :: Verbosity -> GlobalFlags -> [String] -> IO [String]
- userConfigUpdate :: Verbosity -> GlobalFlags -> [String] -> IO ()
- createDefaultConfigFile :: Verbosity -> [String] -> FilePath -> IO SavedConfig
- remoteRepoFields :: [FieldDescr RemoteRepo]
- postProcessRepo :: Int -> String -> RemoteRepo -> ParseResult (Either LocalRepo RemoteRepo)

# Documentation

data SavedConfig #

Constructors

SavedConfig |
Fields savedGlobalFlags :: GlobalFlags savedInitFlags :: InitFlags savedInstallFlags :: InstallFlags savedClientInstallFlags :: ClientInstallFlags savedConfigureFlags :: ConfigFlags savedConfigureExFlags :: ConfigExFlags savedUserInstallDirs :: InstallDirs (Flag PathTemplate) savedGlobalInstallDirs :: InstallDirs (Flag PathTemplate) savedUploadFlags :: UploadFlags savedReportFlags :: ReportFlags savedHaddockFlags :: HaddockFlags savedTestFlags :: TestFlags savedBenchmarkFlags :: BenchmarkFlags savedProjectFlags :: ProjectFlags savedReplMulti :: Flag Bool

#### Instances

Instances details

Monoid SavedConfig # |
Instance details Defined in Distribution.Client.Config Methods mempty :: SavedConfig # mappend :: SavedConfig -> SavedConfig -> SavedConfig # mconcat :: [SavedConfig] -> SavedConfig #
Semigroup SavedConfig # |
Instance details Defined in Distribution.Client.Config Methods (<>) :: SavedConfig -> SavedConfig -> SavedConfig # sconcat :: NonEmpty SavedConfig -> SavedConfig # stimes :: Integral b => b -> SavedConfig -> SavedConfig #
Generic SavedConfig # |
Instance details Defined in Distribution.Client.Config Associated Types
type Rep SavedConfig |
Instance details Defined in Distribution.Client.Config type Rep SavedConfig = D1 ('MetaData "SavedConfig" "Distribution.Client.Config" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "SavedConfig" 'PrefixI 'True) (((S1 ('MetaSel ('Just "savedGlobalFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 GlobalFlags) :*: (S1 ('MetaSel ('Just "savedInitFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InitFlags) :*: S1 ('MetaSel ('Just "savedInstallFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InstallFlags))) :*: ((S1 ('MetaSel ('Just "savedClientInstallFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ClientInstallFlags) :*: S1 ('MetaSel ('Just "savedConfigureFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfigFlags)) :*: (S1 ('MetaSel ('Just "savedConfigureExFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfigExFlags) :*: S1 ('MetaSel ('Just "savedUserInstallDirs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (InstallDirs (Flag PathTemplate)))))) :*: (((S1 ('MetaSel ('Just "savedGlobalInstallDirs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (InstallDirs (Flag PathTemplate))) :*: S1 ('MetaSel ('Just "savedUploadFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UploadFlags)) :*: (S1 ('MetaSel ('Just "savedReportFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReportFlags) :*: S1 ('MetaSel ('Just "savedHaddockFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HaddockFlags))) :*: ((S1 ('MetaSel ('Just "savedTestFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TestFlags) :*: S1 ('MetaSel ('Just "savedBenchmarkFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BenchmarkFlags)) :*: (S1 ('MetaSel ('Just "savedProjectFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ProjectFlags) :*: S1 ('MetaSel ('Just "savedReplMulti") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Flag Bool)))))))
Methods from :: SavedConfig -> Rep SavedConfig x # to :: Rep SavedConfig x -> SavedConfig #
type Rep SavedConfig # |
Instance details Defined in Distribution.Client.Config type Rep SavedConfig = D1 ('MetaData "SavedConfig" "Distribution.Client.Config" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "SavedConfig" 'PrefixI 'True) (((S1 ('MetaSel ('Just "savedGlobalFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 GlobalFlags) :*: (S1 ('MetaSel ('Just "savedInitFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InitFlags) :*: S1 ('MetaSel ('Just "savedInstallFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InstallFlags))) :*: ((S1 ('MetaSel ('Just "savedClientInstallFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ClientInstallFlags) :*: S1 ('MetaSel ('Just "savedConfigureFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfigFlags)) :*: (S1 ('MetaSel ('Just "savedConfigureExFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfigExFlags) :*: S1 ('MetaSel ('Just "savedUserInstallDirs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (InstallDirs (Flag PathTemplate)))))) :*: (((S1 ('MetaSel ('Just "savedGlobalInstallDirs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (InstallDirs (Flag PathTemplate))) :*: S1 ('MetaSel ('Just "savedUploadFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UploadFlags)) :*: (S1 ('MetaSel ('Just "savedReportFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReportFlags) :*: S1 ('MetaSel ('Just "savedHaddockFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HaddockFlags))) :*: ((S1 ('MetaSel ('Just "savedTestFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TestFlags) :*: S1 ('MetaSel ('Just "savedBenchmarkFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BenchmarkFlags)) :*: (S1 ('MetaSel ('Just "savedProjectFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ProjectFlags) :*: S1 ('MetaSel ('Just "savedReplMulti") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Flag Bool)))))))

loadConfig :: Verbosity -> Flag FilePath -> IO SavedConfig #

Loads the main configuration, and applies additional defaults to give the effective configuration. To loads just what is actually in the config file, use `loadRawConfig`.

getConfigFilePath :: Flag FilePath -> IO FilePath #

Returns the config file path, without checking that the file exists. The order of precedence is: input flag, CABAL_CONFIG, default location.

showConfig :: SavedConfig -> String #

showConfigWithComments :: SavedConfig -> SavedConfig -> String #

parseConfig :: ConstraintSource -> SavedConfig -> ByteString -> ParseResult SavedConfig #

defaultConfigFile :: IO FilePath #

defaultCacheDir :: IO FilePath #

defaultCacheHome :: IO FilePath #

defaultScriptBuildsDir :: IO FilePath #

defaultStoreDir :: IO FilePath #

defaultCompiler :: CompilerFlavor #

defaultInstallPath :: IO FilePath #

defaultLogsDir :: IO FilePath #

defaultReportsDir :: IO FilePath #

defaultUserInstall :: Bool #

baseSavedConfig :: IO SavedConfig #

These are the absolute basic defaults. The fields that must be initialised. When we load the config from the file we layer the loaded values over these ones, so any missing fields in the file take their values from here.

commentSavedConfig :: IO SavedConfig #

These are the default values that get used in Cabal if a no value is given. We use these here to include in comments when we write out the initial config file so that the user can see what default value they are overriding.

initialSavedConfig :: IO SavedConfig #

This is the initial configuration that we write out to the config file if the file does not exist (or the config we use if the file cannot be read for some other reason). When the config gets loaded it gets layered on top of `baseSavedConfig` so we do not need to include it into the initial values we save into the config file.

configFieldDescriptions :: ConstraintSource -> [FieldDescr SavedConfig] #

All config file fields.

haddockFlagsFields :: [FieldDescr HaddockFlags] #

Fields for the `haddock` section.

installDirsFields :: [FieldDescr (InstallDirs (Flag PathTemplate))] #

Fields for the 'install-dirs' sections.

withProgramsFields :: [FieldDescr [(String, FilePath)]] #

Fields for the 'program-locations' section.

withProgramOptionsFields :: [FieldDescr [(String, [String])]] #

Fields for the 'program-default-options' section.

userConfigDiff :: Verbosity -> GlobalFlags -> [String] -> IO [String] #

Get the differences (as a pseudo code diff) between the user's config file and the one that cabal would generate if it didn't exist.

userConfigUpdate :: Verbosity -> GlobalFlags -> [String] -> IO () #

Update the user's config file keeping the user's customizations.

createDefaultConfigFile :: Verbosity -> [String] -> FilePath -> IO SavedConfig #

remoteRepoFields :: [FieldDescr RemoteRepo] #

postProcessRepo :: Int -> String -> RemoteRepo -> ParseResult (Either LocalRepo RemoteRepo) #