shellcmd

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAndCaptureOutput

func RunAndCaptureOutput(ctx context.Context, cmd string, env []string) (string, error)

RunAndCaptureOutput runs the command and returns its stdout as a byte slice. If the output is not valid UTF-8 text, this returns an error.

func RunInTerminal

func RunInTerminal(ctx context.Context, cmd string, env []string) error

RunInTerminal runs the command using inputs and outputs of the current process.

func RunSilent

func RunSilent(ctx context.Context, cmd string, env []string) error

RunSilent runs the command and discards any output.

Types

type FileLocation

type FileLocation struct {
	Path    string // Path to the file.
	LineNum uint64 // Line number in the file.
	Snippet string // Snippet of text from the location.
}

FileLocation represents a location within a file.

func FileLocationsFromLines

func FileLocationsFromLines(r io.Reader) ([]FileLocation, error)

FileLocationsFromLines parses each non-empty line as a file location. The supported file location formats are:

<file>:<line>:<col>:<snippet>
<file>:<line>:<snippet>

which correspond to the outputs to `grep -n` and `ripgrep --vimgrep` If any line cannot be parsed, this function aborts and returns an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL