Documentation
¶
Overview ¶
Package cmd provides a CLI command entry point for virtrun. It handles flag parsing, error handling, and output handling.
Index ¶
- Variables
- func EnvArgs() []string
- func LocalConfigArgs(fsys fs.FS, file string) ([]string, error)
- func MergedArgs(cliArgs []string, fsys fs.FS, confFile string) ([]string, error)
- func Run(ctx context.Context, args []string, cfg IO) int
- func ValidateFilePath(name string) error
- type FilePath
- type FilePathList
- type IO
- type LimitedUintValue
- type ParseArgsError
Constants ¶
This section is empty.
Variables ¶
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
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
MergedArgs merges arguments from all sources.
Order of precedence (from higher to lower) is: - CLI args - local config file - environment variable.
func ValidateFilePath ¶ added in v0.12.0
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.
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 LimitedUintValue ¶ added in v0.15.3
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