{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts  #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards   #-}

-- | Handy path information.

module Stack.Path
    ( path
    , pathParser
    ) where

import           Stack.Prelude
import           Data.List (intercalate)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Options.Applicative as OA
import           Path
import           Path.Extra
import           Stack.Constants
import           Stack.Constants.Config
import           Stack.GhcPkg as GhcPkg
import           Stack.Runners
import           Stack.Types.Config
import qualified System.FilePath as FP
import           RIO.PrettyPrint
import           RIO.Process (HasProcessContext (..), exeSearchPathL)

-- | Print out useful path information in a human-readable format (and

-- support others later).

path :: [Text] -> RIO Runner ()
path :: [Text] -> RIO Runner ()
path [Text]
keys =
    do let deprecated :: [(Text, Text)]
deprecated = forall a. (a -> Bool) -> [a] -> [a]
filter ((forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Text]
keys) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) [(Text, Text)]
deprecatedPathKeys
       forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(Text, Text)]
deprecated forall a b. (a -> b) -> a -> b
$ \(Text
oldOption, Text
newOption) -> forall (m :: * -> *) env.
(MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) =>
Utf8Builder -> m ()
logWarn forall a b. (a -> b) -> a -> b
$
           Utf8Builder
"\n" forall a. Semigroup a => a -> a -> a
<>
           Utf8Builder
"'--" forall a. Semigroup a => a -> a -> a
<> forall a. Display a => a -> Utf8Builder
display Text
oldOption forall a. Semigroup a => a -> a -> a
<> Utf8Builder
"' will be removed in a future release.\n" forall a. Semigroup a => a -> a -> a
<>
           Utf8Builder
"Please use '--" forall a. Semigroup a => a -> a -> a
<> forall a. Display a => a -> Utf8Builder
display Text
newOption forall a. Semigroup a => a -> a -> a
<> Utf8Builder
"' instead.\n" forall a. Semigroup a => a -> a -> a
<>
           Utf8Builder
"\n"
       let -- filter the chosen paths in flags (keys),

           -- or show all of them if no specific paths chosen.

           goodPaths :: [(String, Text, UseHaddocks (PathInfo -> Text))]
goodPaths = forall a. (a -> Bool) -> [a] -> [a]
filter
                (\(String
_,Text
key,UseHaddocks (PathInfo -> Text)
_) ->
                      (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Text]
keys Bool -> Bool -> Bool
&& Text
key forall a. Eq a => a -> a -> Bool
/= String -> Text
T.pack String
deprecatedStackRootOptionName) Bool -> Bool -> Bool
|| forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Text
key [Text]
keys)
                [(String, Text, UseHaddocks (PathInfo -> Text))]
paths
           singlePath :: Bool
singlePath = forall (t :: * -> *) a. Foldable t => t a -> Int
length [(String, Text, UseHaddocks (PathInfo -> Text))]
goodPaths forall a. Eq a => a -> a -> Bool
== Int
1
           toEither :: (a, a, UseHaddocks b) -> Either (a, b) (a, b)
toEither (a
_, a
k, UseHaddocks b
p) = forall a b. a -> Either a b
Left (a
k, b
p)
           toEither (a
_, a
k, WithoutHaddocks b
p) = forall a b. b -> Either a b
Right (a
k, b
p)
           ([(Text, PathInfo -> Text)]
with, [(Text, PathInfo -> Text)]
without) = forall a b. [Either a b] -> ([a], [b])
partitionEithers forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall {a} {a} {b}. (a, a, UseHaddocks b) -> Either (a, b) (a, b)
toEither [(String, Text, UseHaddocks (PathInfo -> Text))]
goodPaths
       Bool -> RIO EnvConfig () -> RIO Runner ()
runHaddock Bool
True forall a b. (a -> b) -> a -> b
$ forall env.
HasEnvConfig env =>
[(Text, PathInfo -> Text)] -> Bool -> RIO env ()
printKeys [(Text, PathInfo -> Text)]
with Bool
singlePath
       Bool -> RIO EnvConfig () -> RIO Runner ()
runHaddock Bool
False forall a b. (a -> b) -> a -> b
$ forall env.
HasEnvConfig env =>
[(Text, PathInfo -> Text)] -> Bool -> RIO env ()
printKeys [(Text, PathInfo -> Text)]
without Bool
singlePath

printKeys
  :: HasEnvConfig env
  => [(Text, PathInfo -> Text)]
  -> Bool
  -> RIO env ()
printKeys :: forall env.
HasEnvConfig env =>
[(Text, PathInfo -> Text)] -> Bool -> RIO env ()
printKeys [(Text, PathInfo -> Text)]
extractors Bool
single = do
    PathInfo
pathInfo <- forall env. HasEnvConfig env => RIO env PathInfo
fillPathInfo
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(Text, PathInfo -> Text)]
extractors forall a b. (a -> b) -> a -> b
$ \(Text
key, PathInfo -> Text
extractPath) -> do
       let prefix :: Text
prefix = if Bool
single then Text
"" else Text
key forall a. Semigroup a => a -> a -> a
<> Text
": "
       Text -> IO ()
T.putStrLn forall a b. (a -> b) -> a -> b
$ Text
prefix forall a. Semigroup a => a -> a -> a
<> PathInfo -> Text
extractPath PathInfo
pathInfo

runHaddock :: Bool -> RIO EnvConfig () -> RIO Runner ()
runHaddock :: Bool -> RIO EnvConfig () -> RIO Runner ()
runHaddock Bool
x RIO EnvConfig ()
action = forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local Runner -> Runner
modifyConfig forall a b. (a -> b) -> a -> b
$
  forall a. ShouldReexec -> RIO Config a -> RIO Runner a
withConfig ShouldReexec
YesReexec forall a b. (a -> b) -> a -> b
$
    forall a. RIO EnvConfig a -> RIO Config a
withDefaultEnvConfig RIO EnvConfig ()
action
 where
  modifyConfig :: Runner -> Runner
modifyConfig = forall s t a b. ASetter s t a b -> b -> s -> t
set
    (forall env. HasRunner env => Lens' env GlobalOpts
globalOptsLforall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' GlobalOpts BuildOptsMonoid
globalOptsBuildOptsMonoidLforall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidHaddockL) (forall a. a -> Maybe a
Just Bool
x)

fillPathInfo :: HasEnvConfig env => RIO env PathInfo
fillPathInfo :: forall env. HasEnvConfig env => RIO env PathInfo
fillPathInfo = do
     -- We must use a BuildConfig from an EnvConfig to ensure that it contains the

     -- full environment info including GHC paths etc.

     BuildConfig
piBuildConfig <- forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall env. HasEnvConfig env => Lens' env EnvConfig
envConfigLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasBuildConfig env => Lens' env BuildConfig
buildConfigL
     -- This is the modified 'bin-path',

     -- including the local GHC or MSYS if not configured to operate on

     -- global GHC.

     -- It was set up in 'withBuildConfigAndLock -> withBuildConfigExt -> setupEnv'.

     -- So it's not the *minimal* override path.

     Path Abs Dir
piSnapDb <- forall env. HasEnvConfig env => RIO env (Path Abs Dir)
packageDatabaseDeps
     Path Abs Dir
piLocalDb <- forall env. HasEnvConfig env => RIO env (Path Abs Dir)
packageDatabaseLocal
     [Path Abs Dir]
piExtraDbs <- forall env (m :: * -> *).
(MonadReader env m, HasEnvConfig env) =>
m [Path Abs Dir]
packageDatabaseExtra
     Path Abs Dir
piGlobalDb <- forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall env. HasCompiler env => SimpleGetter env CompilerPaths
compilerPathsLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to CompilerPaths -> Path Abs Dir
cpGlobalDB
     Path Abs Dir
piSnapRoot <- forall env. HasEnvConfig env => RIO env (Path Abs Dir)
installationRootDeps
     Path Abs Dir
piLocalRoot <- forall env. HasEnvConfig env => RIO env (Path Abs Dir)
installationRootLocal
     Path Abs Dir
piToolsDir <- forall (m :: * -> *) env.
(MonadThrow m, MonadReader env m, HasEnvConfig env) =>
m (Path Abs Dir)
bindirCompilerTools
     Path Abs Dir
piHoogleRoot <- forall env. HasEnvConfig env => RIO env (Path Abs Dir)
hoogleRoot
     Path Rel Dir
piDistDir <- forall (m :: * -> *) env.
(MonadThrow m, MonadReader env m, HasEnvConfig env) =>
m (Path Rel Dir)
distRelativeDir
     Path Abs Dir
piHpcDir <- forall env. HasEnvConfig env => RIO env (Path Abs Dir)
hpcReportDir
     Path Abs File
piCompiler <- forall env. HasCompiler env => RIO env (Path Abs File)
getCompilerPath
     forall (m :: * -> *) a. Monad m => a -> m a
return PathInfo {[Path Abs Dir]
Path Abs File
Path Abs Dir
Path Rel Dir
BuildConfig
piCompiler :: Path Abs File
piExtraDbs :: [Path Abs Dir]
piHpcDir :: Path Abs Dir
piDistDir :: Path Rel Dir
piHoogleRoot :: Path Abs Dir
piToolsDir :: Path Abs Dir
piLocalRoot :: Path Abs Dir
piSnapRoot :: Path Abs Dir
piGlobalDb :: Path Abs Dir
piLocalDb :: Path Abs Dir
piSnapDb :: Path Abs Dir
piBuildConfig :: BuildConfig
piCompiler :: Path Abs File
piHpcDir :: Path Abs Dir
piDistDir :: Path Rel Dir
piHoogleRoot :: Path Abs Dir
piToolsDir :: Path Abs Dir
piLocalRoot :: Path Abs Dir
piSnapRoot :: Path Abs Dir
piGlobalDb :: Path Abs Dir
piExtraDbs :: [Path Abs Dir]
piLocalDb :: Path Abs Dir
piSnapDb :: Path Abs Dir
piBuildConfig :: BuildConfig
..}

pathParser :: OA.Parser [Text]
pathParser :: Parser [Text]
pathParser =
    forall (f :: * -> *) a b.
Applicative f =>
(a -> f (Maybe b)) -> [a] -> f [b]
mapMaybeA
        (\(String
desc,Text
name,UseHaddocks (PathInfo -> Text)
_) ->
             forall a. a -> a -> Mod FlagFields a -> Parser a
OA.flag forall a. Maybe a
Nothing
                     (forall a. a -> Maybe a
Just Text
name)
                     (forall (f :: * -> *) a. HasName f => String -> Mod f a
OA.long (Text -> String
T.unpack Text
name) forall a. Semigroup a => a -> a -> a
<>
                      forall (f :: * -> *) a. String -> Mod f a
OA.help String
desc))
        [(String, Text, UseHaddocks (PathInfo -> Text))]
paths

-- | Passed to all the path printers as a source of info.

data PathInfo = PathInfo
    { PathInfo -> BuildConfig
piBuildConfig  :: !BuildConfig
    , PathInfo -> Path Abs Dir
piSnapDb       :: !(Path Abs Dir)
    , PathInfo -> Path Abs Dir
piLocalDb      :: !(Path Abs Dir)
    , PathInfo -> Path Abs Dir
piGlobalDb     :: !(Path Abs Dir)
    , PathInfo -> Path Abs Dir
piSnapRoot     :: !(Path Abs Dir)
    , PathInfo -> Path Abs Dir
piLocalRoot    :: !(Path Abs Dir)
    , PathInfo -> Path Abs Dir
piToolsDir     :: !(Path Abs Dir)
    , PathInfo -> Path Abs Dir
piHoogleRoot   :: !(Path Abs Dir)
    , PathInfo -> Path Rel Dir
piDistDir      :: Path Rel Dir
    , PathInfo -> Path Abs Dir
piHpcDir       :: !(Path Abs Dir)
    , PathInfo -> [Path Abs Dir]
piExtraDbs     :: ![Path Abs Dir]
    , PathInfo -> Path Abs File
piCompiler     :: !(Path Abs File)
    }

instance HasPlatform PathInfo
instance HasLogFunc PathInfo where
    logFuncL :: Lens' PathInfo LogFunc
logFuncL = forall env. HasConfig env => Lens' env Config
configLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasLogFunc env => Lens' env LogFunc
logFuncL
instance HasRunner PathInfo where
    runnerL :: Lens' PathInfo Runner
runnerL = forall env. HasConfig env => Lens' env Config
configLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasRunner env => Lens' env Runner
runnerL
instance HasStylesUpdate PathInfo where
  stylesUpdateL :: Lens' PathInfo StylesUpdate
stylesUpdateL = forall env. HasRunner env => Lens' env Runner
runnerLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasStylesUpdate env => Lens' env StylesUpdate
stylesUpdateL
instance HasTerm PathInfo where
  useColorL :: Lens' PathInfo Bool
useColorL = forall env. HasRunner env => Lens' env Runner
runnerLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasTerm env => Lens' env Bool
useColorL
  termWidthL :: Lens' PathInfo Int
termWidthL = forall env. HasRunner env => Lens' env Runner
runnerLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasTerm env => Lens' env Int
termWidthL
instance HasGHCVariant PathInfo
instance HasConfig PathInfo
instance HasPantryConfig PathInfo where
    pantryConfigL :: Lens' PathInfo PantryConfig
pantryConfigL = forall env. HasConfig env => Lens' env Config
configLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasPantryConfig env => Lens' env PantryConfig
pantryConfigL
instance HasProcessContext PathInfo where
    processContextL :: Lens' PathInfo ProcessContext
processContextL = forall env. HasConfig env => Lens' env Config
configLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall env. HasProcessContext env => Lens' env ProcessContext
processContextL
instance HasBuildConfig PathInfo where
    buildConfigL :: Lens' PathInfo BuildConfig
buildConfigL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens PathInfo -> BuildConfig
piBuildConfig (\PathInfo
x BuildConfig
y -> PathInfo
x { piBuildConfig :: BuildConfig
piBuildConfig = BuildConfig
y })
                 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall env. HasBuildConfig env => Lens' env BuildConfig
buildConfigL

data UseHaddocks a = UseHaddocks a | WithoutHaddocks a

-- | The paths of interest to a user. The first tuple string is used

-- for a description that the optparse flag uses, and the second

-- string as a machine-readable key and also for @--foo@ flags. The user

-- can choose a specific path to list like @--stack-root@. But

-- really it's mainly for the documentation aspect.

--

-- When printing output we generate @PathInfo@ and pass it to the

-- function to generate an appropriate string.  Trailing slashes are

-- removed, see #506

paths :: [(String, Text, UseHaddocks (PathInfo -> Text))]
paths :: [(String, Text, UseHaddocks (PathInfo -> Text))]
paths =
    [ ( String
"Global stack root directory"
      , String -> Text
T.pack String
stackRootOptionName
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall s. HasConfig s => Lens' s (Path Abs Dir)
stackRootLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to forall loc. Path loc Dir -> String
toFilePathNoTrailingSepforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to String -> Text
T.pack))
    , ( String
"Project root (derived from stack.yaml file)"
      , Text
"project-root"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall env r. HasBuildConfig env => Getting r env (Path Abs Dir)
projectRootLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to forall loc. Path loc Dir -> String
toFilePathNoTrailingSepforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to String -> Text
T.pack))
    , ( String
"Configuration location (where the stack.yaml file is)"
      , Text
"config-location"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall env. HasBuildConfig env => Lens' env (Path Abs File)
stackYamlLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to forall b t. Path b t -> String
toFilePathforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to String -> Text
T.pack))
    , ( String
"PATH environment variable"
      , Text
"bin-path"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [[a]] -> [a]
intercalate [Char
FP.searchPathSeparator] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall env. HasProcessContext env => SimpleGetter env [String]
exeSearchPathL)
    , ( String
"Install location for GHC and other core tools (see 'stack ls tools' command)"
      , Text
"programs"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall env. HasConfig env => Lens' env Config
configLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to Config -> Path Abs Dir
configLocalProgramsforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to forall loc. Path loc Dir -> String
toFilePathNoTrailingSepforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to String -> Text
T.pack))
    , ( String
"Compiler binary (e.g. ghc)"
      , Text
"compiler-exe"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall b t. Path b t -> String
toFilePath forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs File
piCompiler )
    , ( String
"Directory containing the compiler binary (e.g. ghc)"
      , Text
"compiler-bin"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall b t. Path b t -> Path b Dir
parent forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs File
piCompiler )
    , ( String
"Directory containing binaries specific to a particular compiler (e.g. intero)"
      , Text
"compiler-tools-bin"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piToolsDir )
    , ( String
"Local bin dir where stack installs executables (e.g. ~/.local/bin (Unix-like OSs) or %APPDATA%\\local\\bin (Windows))"
      , Text
"local-bin"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall env. HasConfig env => Lens' env Config
configLforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to Config -> Path Abs Dir
configLocalBinforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to forall loc. Path loc Dir -> String
toFilePathNoTrailingSepforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. (s -> a) -> SimpleGetter s a
to String -> Text
T.pack)
    , ( String
"Extra include directories"
      , Text
"extra-include-dirs"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ Text -> [Text] -> Text
T.intercalate Text
", " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> [String]
configExtraIncludeDirs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall env. HasConfig env => Lens' env Config
configL )
    , ( String
"Extra library directories"
      , Text
"extra-library-dirs"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ Text -> [Text] -> Text
T.intercalate Text
", " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> [String]
configExtraLibDirs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall env. HasConfig env => Lens' env Config
configL )
    , ( String
"Snapshot package database"
      , Text
"snapshot-pkg-db"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piSnapDb )
    , ( String
"Local project package database"
      , Text
"local-pkg-db"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piLocalDb )
    , ( String
"Global package database"
      , Text
"global-pkg-db"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piGlobalDb )
    , ( String
"GHC_PACKAGE_PATH environment variable"
      , Text
"ghc-package-path"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ \PathInfo
pi' -> Bool
-> Path Abs Dir
-> Path Abs Dir
-> [Path Abs Dir]
-> Path Abs Dir
-> Text
mkGhcPackagePath Bool
True (PathInfo -> Path Abs Dir
piLocalDb PathInfo
pi') (PathInfo -> Path Abs Dir
piSnapDb PathInfo
pi') (PathInfo -> [Path Abs Dir]
piExtraDbs PathInfo
pi') (PathInfo -> Path Abs Dir
piGlobalDb PathInfo
pi'))
    , ( String
"Snapshot installation root"
      , Text
"snapshot-install-root"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piSnapRoot )
    , ( String
"Local project installation root"
      , Text
"local-install-root"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piLocalRoot )
    , ( String
"Snapshot documentation root"
      , Text
"snapshot-doc-root"
      , forall a. a -> UseHaddocks a
UseHaddocks forall a b. (a -> b) -> a -> b
$ \PathInfo
pi' -> String -> Text
T.pack (forall loc. Path loc Dir -> String
toFilePathNoTrailingSep (PathInfo -> Path Abs Dir
piSnapRoot PathInfo
pi' forall b t. Path b Dir -> Path Rel t -> Path b t
</> Path Rel Dir
docDirSuffix)))
    , ( String
"Local project documentation root"
      , Text
"local-doc-root"
      , forall a. a -> UseHaddocks a
UseHaddocks forall a b. (a -> b) -> a -> b
$ \PathInfo
pi' -> String -> Text
T.pack (forall loc. Path loc Dir -> String
toFilePathNoTrailingSep (PathInfo -> Path Abs Dir
piLocalRoot PathInfo
pi' forall b t. Path b Dir -> Path Rel t -> Path b t
</> Path Rel Dir
docDirSuffix)))
    , ( String
"Local project documentation root"
      , Text
"local-hoogle-root"
      , forall a. a -> UseHaddocks a
UseHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piHoogleRoot)
    , ( String
"Dist work directory, relative to package directory"
      , Text
"dist-dir"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Rel Dir
piDistDir )
    , ( String
"Where HPC reports and tix files are stored"
      , Text
"local-hpc-root"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathInfo -> Path Abs Dir
piHpcDir )
    , ( String
"DEPRECATED: Use '--local-bin' instead"
      , Text
"local-bin-path"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> Path Abs Dir
configLocalBin forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall env. HasConfig env => Lens' env Config
configL )
    , ( String
"DEPRECATED: Use '--programs' instead"
      , Text
"ghc-paths"
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> Path Abs Dir
configLocalPrograms forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall env. HasConfig env => Lens' env Config
configL )
    , ( String
"DEPRECATED: Use '--" forall a. Semigroup a => a -> a -> a
<> String
stackRootOptionName forall a. Semigroup a => a -> a -> a
<> String
"' instead"
      , String -> Text
T.pack String
deprecatedStackRootOptionName
      , forall a. a -> UseHaddocks a
WithoutHaddocks forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall loc. Path loc Dir -> String
toFilePathNoTrailingSep forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s. HasConfig s => Lens' s (Path Abs Dir)
stackRootL )
    ]

deprecatedPathKeys :: [(Text, Text)]
deprecatedPathKeys :: [(Text, Text)]
deprecatedPathKeys =
    [ (String -> Text
T.pack String
deprecatedStackRootOptionName, String -> Text
T.pack String
stackRootOptionName)
    , (Text
"ghc-paths", Text
"programs")
    , (Text
"local-bin-path", Text
"local-bin")
    ]