cabal-install-3.10.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

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 the script-builds dir 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 the script-builds dir 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.

-> CurrentCommand

Current Command (usually for error reporting).

-> (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.

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

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

Add add the executable metadata to the context and 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.