command

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdOption

type CmdOption func(*Command)

CmdOption defines a function that applies configuration to a Command

func WithArgs

func WithArgs(args ...any) CmdOption

WithArgs returns a CmdOption that appends positional args for formatting the command template

func WithParser

func WithParser(p parser.Parser) CmdOption

WithParser returns a CmdOption that assigns a parser to handle the raw command result

type Command

type Command struct {
	Template string        // format string for the command, used with fmt.Sprintf
	Args     []any         // values to plug into the template
	Parser   parser.Parser // optional parser to process command output
}

Command represents a shell command with a template, positional arguments, and an optional parser

func New

func New(template string, opts ...CmdOption) *Command

New returns a Command initialized with the given template and applies any CmdOption to it

func (*Command) String

func (c *Command) String() string

String builds the final shell command by applying the template to its arguments

Jump to

Keyboard shortcuts

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