Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utilities to help commands with scripts
Synopsis
- getScriptCacheDirectoryRoot :: IO FilePath
- getScriptHash :: FilePath -> IO String
- getScriptCacheDirectory :: FilePath -> IO FilePath
- ensureScriptCacheDirectory :: Verbosity -> FilePath -> IO FilePath
- withContextAndSelectors :: AcceptNoTargets -> Maybe ComponentKind -> NixStyleFlags a -> [String] -> GlobalFlags -> (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
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 #
:: 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.
RejectNoTargets | |
AcceptNoTargets | return a default |
Instances
Eq AcceptNoTargets Source # | |
Defined in Distribution.Client.ScriptUtils (==) :: AcceptNoTargets -> AcceptNoTargets -> Bool # (/=) :: AcceptNoTargets -> AcceptNoTargets -> Bool # | |
Show AcceptNoTargets Source # | |
Defined in Distribution.Client.ScriptUtils showsPrec :: Int -> AcceptNoTargets -> ShowS # show :: AcceptNoTargets -> String # showList :: [AcceptNoTargets] -> ShowS # |
data TargetContext Source #
Information about the context in which we found the TargetSelector
s.
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
Eq TargetContext Source # | |
Defined in Distribution.Client.ScriptUtils (==) :: TargetContext -> TargetContext -> Bool # (/=) :: TargetContext -> TargetContext -> Bool # | |
Show TargetContext Source # | |
Defined in Distribution.Client.ScriptUtils showsPrec :: Int -> TargetContext -> ShowS # show :: TargetContext -> String # showList :: [TargetContext] -> ShowS # |
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