| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Distribution.Client.ScriptUtils
Description
Utilities to help commands with scripts
Synopsis
- getScriptHash :: FilePath -> IO String
- getScriptCacheDirectory :: FilePath -> IO FilePath
- ensureScriptCacheDirectory :: Verbosity -> FilePath -> IO FilePath
- withContextAndSelectors :: AcceptNoTargets -> Maybe ComponentKind -> NixStyleFlags a -> [String] -> GlobalFlags -> CurrentCommand -> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b) -> IO b
- data AcceptNoTargets
- data TargetContext
- updateContextAndWriteProjectFile :: ProjectBaseContext -> FilePath -> Executable -> IO ProjectBaseContext
- updateContextAndWriteProjectFile' :: ProjectBaseContext -> SourcePackage (PackageLocation (Maybe FilePath)) -> IO ProjectBaseContext
- fakeProjectSourcePackage :: FilePath -> SourcePackage (PackageLocation loc)
- lSrcpkgDescription :: Lens' (SourcePackage loc) GenericPackageDescription
- movedExePath :: UnqualComponentName -> DistDirLayout -> ElaboratedSharedConfig -> ElaboratedConfiguredPackage -> Maybe FilePath
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.
Constructors
| RejectNoTargets | |
| AcceptNoTargets | return a default |
Instances
| Show AcceptNoTargets Source # | |
Defined in Distribution.Client.ScriptUtils Methods showsPrec :: Int -> AcceptNoTargets -> ShowS # show :: AcceptNoTargets -> String # showList :: [AcceptNoTargets] -> ShowS # | |
| Eq AcceptNoTargets Source # | |
Defined in Distribution.Client.ScriptUtils Methods (==) :: AcceptNoTargets -> AcceptNoTargets -> Bool # (/=) :: AcceptNoTargets -> AcceptNoTargets -> Bool # | |
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
| Show TargetContext Source # | |
Defined in Distribution.Client.ScriptUtils Methods showsPrec :: Int -> TargetContext -> ShowS # show :: TargetContext -> String # showList :: [TargetContext] -> ShowS # | |
| Eq TargetContext Source # | |
Defined in Distribution.Client.ScriptUtils Methods (==) :: TargetContext -> TargetContext -> Bool # (/=) :: TargetContext -> TargetContext -> Bool # | |
updateContextAndWriteProjectFile :: ProjectBaseContext -> FilePath -> Executable -> IO ProjectBaseContext Source #
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
movedExePath :: UnqualComponentName -> DistDirLayout -> ElaboratedSharedConfig -> ElaboratedConfiguredPackage -> Maybe FilePath Source #
Find the path of an exe that has been relocated with a "-o" option