Documentation
¶
Overview ¶
GoScriptify ¶
Index ¶
- func BuildDir(dst string, dir string) error
- func BuildFiles(dst string, srcs []string) error
- func CleanScripts(ps []ScriptPath) error
- func CopyScripts(ps []ScriptPath) (err error)
- func FindScript(ps []string) (string, error)
- func FindScriptOrDir(ps []string, useDir bool) (path string, isDir bool, err error)
- func GetBinDest(sources []string, temp string) (binDst, hash string, err error)
- func RunDir(p string)
- func RunExec(p string, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)
- func RunOneScript(scripts ...string)
- func RunOneScriptOrDir(useDir bool, paths ...string)
- func RunScript(p string)
- func RunScriptDirWithOpts(dir string, args []string, opts ScriptOptions) (int, error)
- func RunScriptsWithOpts(scripts, args []string, opts ScriptOptions) (int, error)
- type BuildError
- type ScriptOptions
- type ScriptPath
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDir ¶
BuildDir builds the directory to the destination.
Currently just using the go runtime to build, for simplicity.
func BuildFiles ¶
BuildFiles builds the given sources to the destination
Currently just using the go runtime to build, for simplicity.
func CleanScripts ¶
func CleanScripts(ps []ScriptPath) error
Go through a slice of ScriptPaths removing all ScriptPath.Generated from the file system if their ScriptPath.Clean is true.
func CopyScripts ¶
func CopyScripts(ps []ScriptPath) (err error)
Copy a slice of ScriptPaths from their ScriptPath.Original location to the ScriptPath.Generated location.
func FindScript ¶
FindScript will find a single file from a list of multiple files, and returning the first found filename. This is to support multiple name types, or cases.
Example:
FindScript([]string{"Builder", "builder"})
Will search for both "Builder" and "builder", and return the first found file.
func FindScriptOrDir ¶
FindScriptOrDir will find a single file or dir from a list of paths.
If useDir is true, the found script's directory will be returned. If the script is not in a subdirectory, useDir does nothing. This makes FindScriptOrDir functionally the same as FindScript, with the bonus of accepting an explicit directory as a Script.
Examples:
// This will return "someDir/Builder" if it exists FindScriptOrDir([]string{"someDir/Builder", "Builder"}, false) // This will return "someDir" if "someDir/Builder" exists FindScriptOrDir([]string{"someDir/Builder", "Builder"}, true) // Both will return "Builder" if "someDir/Builder" does not // exist
func GetBinDest ¶
GetBinDest generates a md5 of the source paths, and returns that and the md5 it generated.
func RunDir ¶
func RunDir(p string)
RunDir compiles and runs the given go package directory with global $args and default options - then Exits the process.
IMPORTANT: This exits the process, captures Stdin, and prints to Stdout and Stderr as needed.
func RunExec ¶
Run the given path as an executable, with the supplied args, and forwarding the stdin/out/err.
Return the exit status, and any errors encountered.
func RunOneScript ¶
func RunOneScript(scripts ...string)
RunOneScript will run the first given script that is found. Basically a shorthand for FindScript and RunScript
IMPORTANT: This exits the process, captures Stdin, and prints to Stdout and Stderr as needed.
func RunOneScriptOrDir ¶
RunOneScriptOrDir will run the first given script, or directory, that is found. The "OrDir" version of RunOneScript.
If useDir is true, scripts found in subdirectories will have their immediate parent directory used as the build directory. As if Go build was run with `go build .`. This allows you to match a specific file, like `muta/muta.go` rather than just running the directory blindly.
IMPORTANT: This exits the process, captures Stdin, and prints to Stdout and Stderr as needed.
func RunScript ¶
func RunScript(p string)
RunScript copies, compiles, and runs the given script with global $args, and default options - then Exits the process.
IMPORTANT: This exits the process, captures Stdin, and prints to Stdout and Stderr as needed.
func RunScriptDirWithOpts ¶
func RunScriptDirWithOpts(dir string, args []string, opts ScriptOptions) (int, error)
func RunScriptsWithOpts ¶
func RunScriptsWithOpts(scripts, args []string, opts ScriptOptions) (int, error)
Copy, compile, and run the given script with the given options.
Returns the exit status and any encountered errors
Types ¶
type BuildError ¶
func (*BuildError) Error ¶
func (e *BuildError) Error() string
type ScriptOptions ¶
func NewScriptOptions ¶
func NewScriptOptions() ScriptOptions
NewScriptOptions returns a default script options.
type ScriptPath ¶
type ScriptPath struct { // The original, unmodified script path Original string // The generated script path, which may contain a hash string to make // the file unique (to not replace the Original) Generated string // Whether or not to remove the file at the end. Clean bool }
TODO: Make Clean readonly via hiding and a read method.
func NewScriptPath ¶
func NewScriptPath(h, p string) ScriptPath
func NewScriptPaths ¶
func NewScriptPaths(hash string, paths []string) []ScriptPath
Directories
¶
Path | Synopsis |
---|---|
_test
|
|
# GoScriptify bin Execute the supplied file as go code.
|
# GoScriptify bin Execute the supplied file as go code. |