Documentation
¶
Overview ¶
Package exec allows invoking other commands, including triggering the manual, opening a document, or opening a Web page in the default Web browser. It also provides a representation of the flag value syntax used by the -exec expression in Unix-like find designed to pass the name of a command and its arguments.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindEditor ¶ added in v0.16.1
func FindEditor() string
FindEditor gets the command used for the editor.
func HaveLookPath ¶ added in v0.13.0
func HaveLookPath(pathname string) cli.ContextFilter
HaveLookPath returns a ContextFilter that checks if the given pathname exists on the PATH.
func Open ¶
Open a file or URL, optionally in the given app. Either one or two arguments is specified, the name/URL of the file to open and the name of the app to use. If the argument looks like a URL, then it triggers the use of the protocol handler associated with the protocol if no app is specified.
Types ¶
type ArgList ¶
type ArgList []string
ArgList provides a value that describes a command and its arguments used as a flag, arg, or expression Value. This uses the syntax that the find -exec expression uses, which is terminated by a semi-colon or plus sign. (e.g. -exec COMMAND ; or -exec COMMAND {} +).
func (*ArgList) NewCounter ¶
func (l *ArgList) NewCounter() cli.ArgCounter
func (*ArgList) UsePlaceholder ¶
UsePlaceholder gets whether the arg list ended with +, which is used to indicate that the {} placeholder is to be expanded
type Editor ¶ added in v0.16.0
type Editor struct {
// Data provides the initial content of the temporary file.
// Accepted types: io.Reader, string, or []byte.
Data any
// Mode sets the file permissions on the temporary file.
Mode fs.FileMode
// ModTime, when non-zero, sets the modification time of the temporary file.
ModTime time.Time
// Cmd, when non-nil, is called with the *exec.Cmd created via
// exec.CommandContext before the editor is started, allowing further
// customization (environment variables, extra arguments, etc.).
Cmd func(*eexec.Cmd)
// KeepTempFile when set to true, causes the temporary file not to be deleted
// after the
KeepTempFile bool
// Output receives the output of the editor
Output []byte
}
Editor is a pipeline-enabled value that opens a text editor using OS-specific conventions. The VISUAL environment variable is consulted first, then EDITOR, then an OS-specific fallback.
The fields correspond to those of testing/fstest.MapFile (excluding Sys) and are used to initialize the temporary file the editor opens. Data accepts io.Reader, string, or []byte; the zero value produces an empty file.