usage

package
v7.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ACL                = placeholder{i18n.G("ACL")}
	Address            = placeholder{i18n.G("address")}
	AddressSet         = placeholder{i18n.G("address set")}
	Alias              = placeholder{i18n.G("alias")}
	Backend            = placeholder{i18n.G("backend")}
	BackupFile         = placeholder{i18n.G("backup file")}
	Bucket             = placeholder{i18n.G("bucket")}
	Client             = placeholder{i18n.G("client")}
	CommandLine        = list{placeholder{i18n.G("command-line argument")}, 1, " "}
	Default            = placeholder{i18n.G("default")}
	Device             = placeholder{i18n.G("device")}
	Direction          = alternative{[]Atom{verbatim{"ingress"}, verbatim{"egress"}}}
	Directory          = placeholder{i18n.G("directory")}
	Driver             = placeholder{i18n.G("driver")}
	EndOfFlags         = hide{optional{verbatim{"--"}}, verbatim{"[flags] [--]"}}
	Expiry             = placeholder{i18n.G("expiry")}
	File               = placeholder{i18n.G("file")}
	Filter             = placeholder{i18n.G("filter")}
	Fingerprint        = placeholder{i18n.G("fingerprint")}
	Group              = placeholder{i18n.G("group")}
	Image              = placeholder{i18n.G("image")}
	Instance           = placeholder{i18n.G("instance")}
	Interface          = placeholder{i18n.G("interface")}
	ListenAddress      = placeholder{i18n.G("listen address")}
	ListenPort         = placeholder{i18n.G("listen port")}
	KeepaliveTimeout   = placeholder{i18n.G("keepalive timeout")}
	Key                = placeholder{i18n.G("key")}
	KV                 = compound{"=", []Atom{Key, Value}}
	Member             = placeholder{i18n.G("member")}
	Network            = placeholder{i18n.G("network")}
	NetworkIntegration = placeholder{i18n.G("network integration")}
	Operation          = placeholder{i18n.G("operation")}
	Path               = placeholder{i18n.G("path")}
	Peer               = placeholder{i18n.G("peer")}
	Pool               = placeholder{i18n.G("pool")}
	Port               = placeholder{i18n.G("port")}
	Profile            = placeholder{i18n.G("profile")}
	Project            = placeholder{i18n.G("project")}
	Protocol           = placeholder{i18n.G("protocol")}
	Query              = placeholder{i18n.G("query")}
	Record             = placeholder{i18n.G("record")}
	Remote             = placeholder{i18n.G("remote")}
	RemoteColon        = remote{Remote, nil, false}
	RemoteColonOpt     = remote{Remote, nil, true}
	RemoteImage        = compound{":", []Atom{optional{Remote}, Image}}
	Role               = placeholder{i18n.G("role")}
	Snapshot           = placeholder{i18n.G("snapshot")}
	StorageVolumeType  = hide{alternative{[]Atom{verbatim{"custom"}, verbatim{"image"}, verbatim{"container"}, verbatim{"virtual-machine"}}}, placeholder{i18n.G("type")}}
	SymlinkTargetPath  = placeholder{i18n.G("symlink target path")}
	Tarball            = placeholder{i18n.G("tarball")}
	Template           = placeholder{i18n.G("template")}
	Token              = placeholder{i18n.G("token")}
	Type               = placeholder{i18n.G("type")}
	URL                = placeholder{i18n.G("URL")}
	Value              = placeholder{i18n.G("value")}
	Volume             = placeholder{i18n.G("volume")}
	WarningUUID        = placeholder{i18n.G("warning UUID")}
	Zone               = placeholder{i18n.G("zone")}
)

A few strings used throughout the Incus client.

View Source
var ErrExplainOnly = errors.New(i18n.G("This command was called with --explain; its arguments are valid, but no further processing is done"))

ErrExplainOnly is returned when --explain is used and the CLI invocation is valid.

View Source
var LegacyKV = hide{alternative{[]Atom{compound{"=", []Atom{Key, Value}}, deprecated{compound{" ", []Atom{Key, Value}}, i18n.G("please switch to the “<key>=<value>” syntax")}}}, compound{"=", []Atom{Key, Value}}}

LegacyKV is a backward-compatible key/value parsing atom.

Functions

func MakeRemote

func MakeRemote(atom Atom, optional bool) remote

MakeRemote transforms an atom into a remote.

func Placeholder

func Placeholder(element string) placeholder

Placeholder builds a placeholder atom from a string.

func Verbatim

func Verbatim(element string) verbatim

Verbatim builds a verbatim atom from a string.

Types

type Atom

type Atom interface {
	List(minOccurrences int, separator ...string) Atom
	Optional(chain ...Atom) Atom
	Parse(conf Config, servers map[string]incus.InstanceServer, args *[]string) (*Parsed, error)
	Render() string
	Remote() Atom
}

Atom is the type of command-line atoms.

func Colon

func Colon(a Atom) Atom

Colon suffixes an atom with `:`.

func Either

func Either(atoms ...Atom) Atom

Either builds an alternative atom from several atoms.

func EitherPlaceholder

func EitherPlaceholder(elements ...string) Atom

EitherPlaceholder builds an alternative of placeholder atoms from several strings.

func EitherVerbatim

func EitherVerbatim(elements ...string) Atom

EitherVerbatim builds an alternative of verbatim atoms from several strings.

func Flag

func Flag(name string) Atom

Flag builds a flag atom from a string.

func MakePath

func MakePath(atoms ...Atom) Atom

MakePath builds an atom compound separated by `/`.

func NewName

func NewName(p placeholder) Atom

NewName transforms a placeholder (e.g. `<foo>`) into a placeholder suggesting that a new name is requested (e.g. `<new foo name>`).

func Sequence

func Sequence(atoms ...Atom) Atom

Sequence builds a space-separated sequence of atoms.

func Target

func Target(p placeholder) Atom

Target transforms a placeholder (e.g. `<foo>`) into a placeholder suggesting that the requested object is the target of an operation (e.g. `<target foo>`).

type Config added in v7.0.1

type Config struct {
	CLIConfig     *cliconfig.Config
	CLIConfigPath string
	Command       *cobra.Command
	ExplainOnly   bool
	RTL           bool
}

Config is the type of parser configurations.

func (*Config) SaveCLIConfig added in v7.0.1

func (c *Config) SaveCLIConfig() error

SaveCLIConfig saves the client configuration.

type Parsed

type Parsed struct {

	// The remote name, if the parsed atom describes a remote.
	RemoteName string
	// The remote instance server, if the parsed atom describes a remote.
	RemoteServer incus.InstanceServer
	// The remote object parsed sub-atom, if the parsed atom describes a remote.
	RemoteObject *Parsed
	// The string argument(s) mapped to this parsed atom.
	String string
	// The parsed sub-atoms.
	List []*Parsed
	// The parsed sub-atoms as strings.
	StringList []string

	// Whether the atom parsing has been skipped.
	Skipped bool
	// The branch number of an alternative.
	BranchID int
	// contains filtered or unexported fields
}

Parsed is the type of parsed atoms.

func ParseDefault

func ParseDefault(atom Atom, conf *cliconfig.Config) (*Parsed, error)

ParseDefault returns a parsed atom corresponding to how the given atom is parsed without any argument.

func ParseString

func ParseString(s string) *Parsed

ParseString returns a parsed atom corresponding to a single string.

func (Parsed) Get

func (p Parsed) Get(def string) string

Get gets a parsed atom’s string representation, or a default value if the atom was skipped.

type Usage

type Usage []Atom

Usage is the type of CLI usages.

func (Usage) Parse

func (u Usage) Parse(conf Config, args []string) ([]*Parsed, error)

Parse parses a usage.

Jump to

Keyboard shortcuts

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