Documentation ¶
Index ¶
- func CopyDir(src string, dst string) (err error)
- func CopyFile(src, dst string) (err error)
- func Kill(cmd *exec.Cmd) error
- func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) error
- func RunLineOutputCmd(cmd *exec.Cmd, onLine func(line string) (bool, error)) error
- type OSCommand
- func (c *OSCommand) AppendLineToFile(filename, line string) error
- func (c *OSCommand) CopyToClipboard(str string) error
- func (c *OSCommand) CreateFileWithContent(path string, content string) error
- func (c *OSCommand) CreateTempFile(filename, content string) (string, error)
- func (c *OSCommand) DetectUnamePass(command string, promptUserForCredential func(string) string) error
- func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error)
- func (c *OSCommand) ExecutableFromString(commandStr string) *exec.Cmd
- func (c *OSCommand) FileExists(path string) (bool, error)
- func (c *OSCommand) FileType(path string) string
- func (c *OSCommand) GetLazygitPath() string
- func (c *OSCommand) OpenFile(filename string) error
- func (c *OSCommand) OpenLink(link string) error
- func (c *OSCommand) PipeCommands(commandStrings ...string) error
- func (c *OSCommand) PrepareSubProcess(cmdName string, commandArgs ...string) *exec.Cmd
- func (c *OSCommand) Quote(message string) string
- func (c *OSCommand) Remove(filename string) error
- func (c *OSCommand) RunCommand(formatString string, formatArgs ...interface{}) error
- func (c *OSCommand) RunCommandWithOptions(command string, options RunCommandOptions) error
- func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...interface{}) (string, error)
- func (c *OSCommand) RunCommandWithOutputLive(command string, output func(string) string) error
- func (c *OSCommand) RunCommandWithOutputWithOptions(command string, options RunCommandOptions) (string, error)
- func (c *OSCommand) RunCustomCommand(command string) *exec.Cmd
- func (c *OSCommand) RunDirectCommand(command string) (string, error)
- func (c *OSCommand) RunExecutable(cmd *exec.Cmd) error
- func (c *OSCommand) RunExecutableWithOutput(cmd *exec.Cmd) (string, error)
- func (c *OSCommand) RunPreparedCommand(cmd *exec.Cmd) error
- func (c *OSCommand) SetBeforeExecuteCmd(cmd func(*exec.Cmd))
- func (c *OSCommand) SetCommand(cmd func(string, ...string) *exec.Cmd)
- func (c *OSCommand) ShellCommandFromString(commandStr string) *exec.Cmd
- func (c *OSCommand) Unquote(message string) string
- type Platform
- type RunCommandOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist. If destination already exists we'll clobber it. Symlinks are ignored and skipped.
func CopyFile ¶
CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.
func RunCommandWithOutputLiveWrapper ¶
func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) error
RunCommandWithOutputLiveWrapper runs a command and return every word that gets written in stdout Output is a function that executes by every word that gets read by bufio As return of output you need to give a string that will be written to stdin NOTE: If the return data is empty it won't written anything to stdin
Types ¶
type OSCommand ¶
type OSCommand struct { Log *logrus.Entry Platform *Platform Config config.AppConfigurer Command func(string, ...string) *exec.Cmd BeforeExecuteCmd func(*exec.Cmd) GetGlobalGitConfig func(string) (string, error) Getenv func(string) string }
OSCommand holds all the os commands
func NewDummyOSCommand ¶
func NewDummyOSCommand() *OSCommand
NewDummyOSCommand creates a new dummy OSCommand for testing
func NewOSCommand ¶
func NewOSCommand(log *logrus.Entry, config config.AppConfigurer) *OSCommand
NewOSCommand os command runner
func (*OSCommand) AppendLineToFile ¶
AppendLineToFile adds a new line in file
func (*OSCommand) CopyToClipboard ¶
func (*OSCommand) CreateFileWithContent ¶
CreateFileWithContent creates a file with the given content
func (*OSCommand) CreateTempFile ¶
CreateTempFile writes a string to a new temp file and returns the file's name
func (*OSCommand) DetectUnamePass ¶
func (c *OSCommand) DetectUnamePass(command string, promptUserForCredential func(string) string) error
DetectUnamePass detect a username / password / passphrase question in a command promptUserForCredential is a function that gets executed when this function detect you need to fillin a password or passphrase The promptUserForCredential argument will be "username", "password" or "passphrase" and expects the user's password/passphrase or username back
func (*OSCommand) EditFile ¶
EditFile opens a file in a subprocess using whatever editor is available, falling back to core.editor, VISUAL, EDITOR, then vi
func (*OSCommand) ExecutableFromString ¶
ExecutableFromString takes a string like `git status` and returns an executable command for it
func (*OSCommand) FileExists ¶
FileExists checks whether a file exists at the specified path
func (*OSCommand) GetLazygitPath ¶
GetLazygitPath returns the path of the currently executed file
func (*OSCommand) PipeCommands ¶
PipeCommands runs a heap of commands and pipes their inputs/outputs together like A | B | C
func (*OSCommand) PrepareSubProcess ¶
PrepareSubProcess iniPrepareSubProcessrocess then tells the Gui to switch to it TODO: see if this needs to exist, given that ExecutableFromString does the same things
func (*OSCommand) RunCommand ¶
RunCommand runs a command and just returns the error
func (*OSCommand) RunCommandWithOptions ¶
func (c *OSCommand) RunCommandWithOptions(command string, options RunCommandOptions) error
func (*OSCommand) RunCommandWithOutput ¶
func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...interface{}) (string, error)
RunCommandWithOutput wrapper around commands returning their output and error NOTE: If you don't pass any formatArgs we'll just use the command directly, however there's a bizarre compiler error/warning when you pass in a formatString with a percent sign because it thinks it's supposed to be a formatString when in that case it's not. To get around that error you'll need to define the string in a variable and pass the variable into RunCommandWithOutput.
func (*OSCommand) RunCommandWithOutputLive ¶
RunCommandWithOutputLive runs RunCommandWithOutputLiveWrapper
func (*OSCommand) RunCommandWithOutputWithOptions ¶
func (c *OSCommand) RunCommandWithOutputWithOptions(command string, options RunCommandOptions) (string, error)
func (*OSCommand) RunCustomCommand ¶
RunCustomCommand returns the pointer to a custom command
func (*OSCommand) RunDirectCommand ¶
RunDirectCommand wrapper around direct commands
func (*OSCommand) RunExecutable ¶
RunExecutable runs an executable file and returns an error if there was one
func (*OSCommand) RunExecutableWithOutput ¶
RunExecutableWithOutput runs an executable file and returns its output
func (*OSCommand) RunPreparedCommand ¶
RunPreparedCommand takes a pointer to an exec.Cmd and runs it this is useful if you need to give your command some environment variables before running it
func (*OSCommand) SetBeforeExecuteCmd ¶
func (*OSCommand) SetCommand ¶
SetCommand sets the command function used by the struct. To be used for testing only
func (*OSCommand) ShellCommandFromString ¶
ShellCommandFromString takes a string like `git commit` and returns an executable shell command for it
type Platform ¶
type Platform struct { OS string CatCmd string Shell string ShellArg string EscapedQuote string OpenCommand string OpenLinkCommand string FallbackEscapedQuote string }
Platform stores the os state
type RunCommandOptions ¶
type RunCommandOptions struct {
EnvVars []string
}