Documentation
¶
Index ¶
- func ExeName(path string) string
- type Bsh
- func (b *Bsh) Append(path string, contents string)
- func (b *Bsh) AppendBytes(path string, data []byte)
- func (b *Bsh) AppendBytesErr(path string, data []byte) error
- func (b *Bsh) AppendErr(path string, contents string) error
- func (b *Bsh) Appendf(path string, format string, args ...interface{})
- func (b *Bsh) Ask(msg string) string
- func (b *Bsh) Askf(format string, args ...interface{}) string
- func (b *Bsh) Chdir(dir string)
- func (b *Bsh) Cmd(command string) *Command
- func (b *Bsh) Cmdf(format string, args ...interface{}) *Command
- func (b *Bsh) Copy(src, dst string) bool
- func (b *Bsh) CopyContents(src, dst string)
- func (b *Bsh) Echo(str string)
- func (b *Bsh) Echof(format string, args ...interface{})
- func (b *Bsh) ExeName(path string) string
- func (b *Bsh) Exists(path string) bool
- func (b *Bsh) Getwd() string
- func (b *Bsh) InDir(path string, fn func())
- func (b *Bsh) InTempDir(fn func())
- func (b *Bsh) IsDir(path string) bool
- func (b *Bsh) IsExeInPath(file string) bool
- func (b *Bsh) IsFile(path string) bool
- func (b *Bsh) IsVerbose() bool
- func (b *Bsh) MkdirAll(dir string)
- func (b *Bsh) MkdirTemp() (tmpdir string, cleanup func())
- func (b *Bsh) Must(err error)
- func (b *Bsh) MustCopy(src, dst string)
- func (b *Bsh) Panic(err error)
- func (b *Bsh) PopEchoFilter()
- func (b *Bsh) PushEchoFilter(str string)
- func (b *Bsh) Read(path string) string
- func (b *Bsh) ReadErr(path string) (string, error)
- func (b *Bsh) ReadFile(path string) []byte
- func (b *Bsh) Remove(dir string)
- func (b *Bsh) RemoveAll(dir string)
- func (b *Bsh) ScanLine() string
- func (b *Bsh) ScanLineErr() (string, error)
- func (b *Bsh) SetErrorHandler(fnErr func(error))
- func (b *Bsh) SetVerbose(v bool)
- func (b *Bsh) SetVerboseEnvVarName(s string)
- func (b *Bsh) Stat(path string) fs.FileInfo
- func (b *Bsh) Touch(path string)
- func (b *Bsh) Verbose(str string)
- func (b *Bsh) Verbosef(format string, args ...interface{})
- func (b *Bsh) Warn(str string)
- func (b *Bsh) Warnf(format string, args ...interface{})
- func (b *Bsh) Write(path string, contents string)
- func (b *Bsh) WriteBytes(path string, data []byte)
- func (b *Bsh) WriteBytesErr(path string, data []byte) error
- func (b *Bsh) WriteErr(path string, contents string) error
- func (b *Bsh) Writef(path string, format string, args ...interface{})
- func (b *Bsh) ZipFile(source, target string)
- func (b *Bsh) ZipFileMode(source, target string, mode fs.FileMode)
- func (b *Bsh) ZipFolder(source, target string)
- type Command
- func (c *Command) Bash()
- func (c *Command) BashErr() error
- func (c *Command) BashExitStatus() int
- func (c *Command) BashStr() string
- func (c *Command) Dir(dir string) *Command
- func (c *Command) Env(vars ...string) *Command
- func (c *Command) Err(w io.Writer) *Command
- func (c *Command) ExitStatus(n *int) *Command
- func (c *Command) ExpandEnv() *Command
- func (c *Command) In(r io.Reader) *Command
- func (c *Command) Out(w io.Writer) *Command
- func (c *Command) OutErr(w io.Writer) *Command
- func (c *Command) Run()
- func (c *Command) RunErr() error
- func (c *Command) RunExitStatus() int
- func (c *Command) RunStr() string
- func (c *Command) StdErr() io.Writer
- func (c *Command) StdIn() io.Reader
- func (c *Command) StdOut() io.Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bsh ¶
type Bsh struct { Stdin io.Reader Stdout io.Writer Stderr io.Writer DisableColor bool // contains filtered or unexported fields }
func (*Bsh) AppendBytes ¶
func (*Bsh) Copy ¶ added in v0.1.4
Copy attempts to open file at src and create/overwrite new file at dst, then copy the contents. If src does not exist, Copy returns false, otherwise it returns true. Other errors will panic.
func (*Bsh) CopyContents ¶ added in v0.2.1
CopyContents finds all files/folders contained in src, and then copies them into dst, in that order. This ensures copying into a subfolder of src doesn't recurse forever. Src and dst must both exist and be folders. Duplicates in dst will be overwritten.
func (*Bsh) Exists ¶
Exists checks if this path already exists on disc (as a file or folder or whatever)
func (*Bsh) InDir ¶ added in v0.1.1
InDir saves the cwd, creates the given path (if needed), cds into the given path, executes the given func, then restores the previous cwd.
func (*Bsh) InTempDir ¶ added in v0.2.2
func (b *Bsh) InTempDir(fn func())
InTempDir is like InDir, but uses a unique and newly created temp folder instead of a passed folder name. The temp folder is deleted before this func returns.
func (*Bsh) IsDir ¶
IsDir checks if this path is a folder (returns false if path doesn't exist, or exists but is a file)
func (*Bsh) IsExeInPath ¶ added in v0.2.2
IsExeInPath calls exec.LookPath to locate an executable in the PATH environment var. Returns true if the given executable is found, otherwise false.
func (*Bsh) IsFile ¶
IsFile checks if this path is a file (returns false if path doesn't exist, or exists but is a folder)
func (*Bsh) MkdirTemp ¶ added in v0.2.2
MkdirTemp creates a new temp folder and returns its path and a cleanup function. The cleanup function deletes the temp folder and all its contents.
func (*Bsh) MustCopy ¶ added in v0.1.4
MustCopy attempts to open file at src and create/overwrite new file at dst, then copy the contents. Any error in this process will panic.
func (*Bsh) Panic ¶
Panic is called internally any time there's an unhandled error. It will in turn call any error handler set by SetErrorHandler, or panic() if no error handler was set.
func (*Bsh) PopEchoFilter ¶
func (b *Bsh) PopEchoFilter()
func (*Bsh) PushEchoFilter ¶
func (*Bsh) ScanLineErr ¶
func (*Bsh) SetErrorHandler ¶
SetErrorHandler sets the behavior when an error is encountered while running most commands. The default behavior is to panic.
func (*Bsh) SetVerbose ¶
func (*Bsh) SetVerboseEnvVarName ¶
SetVerboseEnvVarName allows changing the name of the environment variable that is used to decide if we are in Verbose mode. This function creates the new env var immediately, setting its value to true or false based on the value of the old env var name.
func (*Bsh) Touch ¶ added in v0.2.0
Touch creates a file if it doesn't exist, and creates any intermediate folders needed.
func (*Bsh) WriteBytes ¶
func (*Bsh) ZipFileMode ¶ added in v0.2.0
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
func (*Command) BashExitStatus ¶
func (*Command) Env ¶
Env adds environment variables in the form "KEY=VALUE", to be set on exec.Cmd.Env. Note: these env vars are not seen by ExpandEnv.
func (*Command) ExitStatus ¶
func (*Command) ExpandEnv ¶
ExpandEnv calls os.ExpandEnv on the command string before it is parsed and passed to exec.Cmd.