cabal-install-3.8.1.0: The command-line interface for Cabal and Hackage.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Distribution.Client.ScriptUtils

Description

Utilities to help commands with scripts

Synopsis

Documentation

getScriptCacheDirectoryRoot :: IO FilePath Source #

Get the directory where script builds are cached.

CABAL_DIR/script-builds/

getScriptHash :: FilePath -> IO String Source #

Get the hash of a script's absolute path)

Two hashes will be the same as long as the absolute paths are the same.

getScriptCacheDirectory :: FilePath -> IO FilePath Source #

Get the directory for caching a script build.

The only identity of a script is it's absolute path, so append the hashed path to CABAL_DIR/script-builds/ to get the cache directory.

ensureScriptCacheDirectory :: Verbosity -> FilePath -> IO FilePath Source #

Get the directory for caching a script build and ensure it exists.

The only identity of a script is it's absolute path, so append the hashed path to CABAL_DIR/script-builds/ to get the cache directory.

withContextAndSelectors Source #

Arguments

:: AcceptNoTargets

What your command should do when no targets are found.

-> Maybe ComponentKind

A target filter

-> NixStyleFlags a

Command line flags

-> [String]

Target strings or a script and args.

-> GlobalFlags

Global flags.

-> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b)

The body of your command action.

-> IO b 

Determine whether the targets represent regular targets or a script and return the proper context and target selectors. Die with an error message if selectors are valid as neither regular targets or as a script.

In the case that the context refers to a temporary directory, delete it after the action finishes.

data AcceptNoTargets Source #

What your command should do when no targets are found.

Instances

Instances details
Show AcceptNoTargets Source # 
Instance details

Defined in Distribution.Client.ScriptUtils

Methods

showsPrec :: Int -> AcceptNoTargets -> ShowS

show :: AcceptNoTargets -> String

showList :: [AcceptNoTargets] -> ShowS

Eq AcceptNoTargets Source # 
Instance details

Defined in Distribution.Client.ScriptUtils

data TargetContext Source #

Information about the context in which we found the TargetSelectors.

Constructors

ProjectContext

The target selectors are part of a project.

GlobalContext

The target selectors are from the global context.

ScriptContext FilePath Executable

The target selectors refer to a script. Contains the path to the script and the executable metadata parsed from the script

Instances

Instances details
Show TargetContext Source # 
Instance details

Defined in Distribution.Client.ScriptUtils

Methods

showsPrec :: Int -> TargetContext -> ShowS

show :: TargetContext -> String

showList :: [TargetContext] -> ShowS

Eq TargetContext Source # 
Instance details

Defined in Distribution.Client.ScriptUtils

updateContextAndWriteProjectFile :: ProjectBaseContext -> FilePath -> Executable -> IO ProjectBaseContext Source #

Add add the executable metadata to the context and write a .cabal file.

updateContextAndWriteProjectFile' :: ProjectBaseContext -> SourcePackage (PackageLocation (Maybe FilePath)) -> IO ProjectBaseContext Source #

Add the SourcePackage to the context and use it to write a .cabal file.

fakeProjectSourcePackage :: FilePath -> SourcePackage (PackageLocation loc) Source #

The base for making a SourcePackage for a fake project. It needs a Library or Executable depending on the command.

lSrcpkgDescription :: Lens' (SourcePackage loc) GenericPackageDescription Source #

A lens for the srcpkgDescription field of SourcePackage