cmd

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cmd provides a CLI command entry point for virtrun. It handles flag parsing, error handling, and output handling.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHelp aliases [flag.ErrHelp].
	ErrHelp = flag.ErrHelp

	// ErrReadBuildInfo is returned if the go build info can not be read.
	ErrReadBuildInfo = errors.New("can't read build info")

	// ErrNotRegularFile is returned if a file should be read but is not a
	// regular file.
	ErrNotRegularFile = errors.New("not a regular file")

	// ErrValueOutOfRange is returned if a given value is outside of the
	// supported range.
	ErrValueOutOfRange = errors.New("value is outside of range")
)

Functions

func EnvArgs added in v0.15.0

func EnvArgs() []string

EnvArgs returns virtrun arguments from the environment.

func LocalConfigArgs added in v0.15.0

func LocalConfigArgs(fsys fs.FS, file string) ([]string, error)

LocalConfigArgs returns virtrun arguments from a local config file.

The file's format is one argument per line. Environment variables may be used and are expanded with os.ExpandEnv.

func MergedArgs added in v0.15.3

func MergedArgs(
	cliArgs []string,
	fsys fs.FS,
	confFile string,
) ([]string, error)

MergedArgs merges arguments from all sources.

Order of precedence (from higher to lower) is: - CLI args - local config file - environment variable.

func Run

func Run(ctx context.Context, args []string, cfg IO) int

Run is the main entry point for the CLI command.

func ValidateFilePath added in v0.12.0

func ValidateFilePath(name string) error

ValidateFilePath validates that the file with the given name is an existing regular file.

Types

type FilePath added in v0.12.0

type FilePath string

FilePath is an absolute path of an existing regular file.

func (*FilePath) Set added in v0.12.0

func (f *FilePath) Set(input string) error

Set sets FilePath to the given path, if valid.

func (*FilePath) String added in v0.12.0

func (f *FilePath) String() string

type FilePathList added in v0.12.0

type FilePathList []string

FilePathList is a list of absolute paths of existing regular files.

func (*FilePathList) Set added in v0.12.0

func (f *FilePathList) Set(input string) error

Set adds the given file path to the list, if valid. An empty string clears the list.

func (*FilePathList) String added in v0.12.0

func (f *FilePathList) String() string

type IO added in v0.15.3

type IO struct {
	Stdin  *os.File
	Stdout *os.File
	Stderr *os.File
}

IO provides input and output details for the command.

type LimitedUintValue added in v0.15.3

type LimitedUintValue struct {
	Value        *uint64
	Lower, Upper uint64
}

LimitedUintValue is a uint64 with lower and upper limits.

func (*LimitedUintValue) Set added in v0.15.3

func (u *LimitedUintValue) Set(s string) error

Set sets LimitedUintValue to the given value, if valid.

func (*LimitedUintValue) String added in v0.15.3

func (u *LimitedUintValue) String() string

type ParseArgsError

type ParseArgsError struct {
	// contains filtered or unexported fields
}

ParseArgsError wraps errors that occur during argument parsing.

func (*ParseArgsError) Error

func (e *ParseArgsError) Error() string

func (*ParseArgsError) Is

func (*ParseArgsError) Is(other error) bool

Is returns true if the given other error is a ParseArgsError.

func (*ParseArgsError) Unwrap

func (e *ParseArgsError) Unwrap() error

Jump to

Keyboard shortcuts

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