command

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package command provides utilities to manage and execute shell commands. It supports executing individual commands, combining multiple commands into one, and running those commands within a specified environment. Additionally, the package offers methods for initializing, executing, and handling installation of commands, often in conjunction with external tools like mvdan/sh for shell script parsing and execution.

The Commands type represents a collection of shell commands that can be processed together. The Command type encapsulates a single shell command, with methods to manipulate, format, and execute it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command string

Command represents a shell command as a string.

func (*Command) From

func (c *Command) From(command string)

From assigns a new shell command string to the Command.

func (*Command) Shell

func (c *Command) Shell(env ...string) (string, error)

Shell runs the Command using mvdan/sh, capturing both stdout and stderr output. It accepts optional environment variables and returns the stdout output and any errors encountered.

func (*Command) String

func (c *Command) String() string

String returns the Command as a string.

type Commands

type Commands []Command

Commands represents a slice of shell commands.

func (*Commands) Combined

func (c *Commands) Combined() Command

Combined returns all commands in the Commands slice as a single Command, with each command joined by semicolons.

func (*Commands) Exe

func (c *Commands) Exe() error

Exe executes the commands.

func (*Commands) Get

func (c *Commands) Get(_ string) string

Get retrieves a specific attribute of the commands.

func (*Commands) Initialize

func (c *Commands) Initialize(command string) error

Initialize prepares the Commands based on the given string.

func (*Commands) Install

func (c *Commands) Install(d common.InstallData) (output string, found file.File, err error)

Install runs the combined commands for installation using the provided InstallData, captures the output, and returns it alongside any errors or found file information.

func (*Commands) Path

func (c *Commands) Path(path string, patterns []string, _ string, _ match.Requirements) error

Path sets up the path for the commands, using the provided parameters.

func (*Commands) Version

func (c *Commands) Version(version string) error

Version sets the version for the commands.

Jump to

Keyboard shortcuts

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