Documentation ¶
Overview ¶
Package args provides the type that represents the Arguments passed to a command within an invocation.Token as well as a convenient Add method to incrementally build the underlying map.
Index ¶
- Variables
- type Args
- func (a *Args) Add(key string, val any) error
- func (a *Args) Clone() *Args
- func (a *Args) Equals(other *Args) bool
- func (a *Args) GetNode(key string) (ipld.Node, error)
- func (a *Args) Include(other Iterator)
- func (a *Args) Iter() iter.Seq2[string, ipld.Node]
- func (a *Args) Len() int
- func (a *Args) ReadOnly() ReadOnly
- func (a *Args) String() string
- func (a *Args) ToIPLD() (ipld.Node, error)
- func (a *Args) Validate() error
- type Builder
- type Iterator
- type ReadOnly
- func (r ReadOnly) Equals(other ReadOnly) bool
- func (r ReadOnly) GetNode(key string) (ipld.Node, error)
- func (r ReadOnly) Iter() iter.Seq2[string, ipld.Node]
- func (r ReadOnly) Len() int
- func (r ReadOnly) String() string
- func (r ReadOnly) ToIPLD() (ipld.Node, error)
- func (r ReadOnly) WriteableClone() *Args
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("key not found in meta")
Functions ¶
This section is empty.
Types ¶
type Args ¶
Args are the Command's arguments when an invocation Token is processed by the executor. This also serves as a way to construct the underlying IPLD data with minimum allocations and transformations, while hiding the IPLD complexity from the caller.
func (*Args) Add ¶
Add inserts a key/value pair in the Args set.
Accepted types for val are any CBOR compatible type, or directly IPLD values.
func (*Args) GetNode ¶
GetNode retrieves a value as a raw IPLD node. Returns ErrNotFound if the given key is missing.
func (*Args) Include ¶
Include merges the provided arguments into the existing arguments.
If duplicate keys are encountered, the new value is silently dropped without causing an error.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder allows the fluid construction of an Args.
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder returns a Builder which will assemble the Args.
func (*Builder) Add ¶
Add inserts a new key/val into the Args being assembled while collecting any errors caused by duplicate keys.
func (*Builder) Build ¶
Build returns the assembled Args or an error containing a list of errors encountered while trying to build the Args.
func (*Builder) BuildIPLD ¶
BuildIPLD is the same as Build except it takes the additional step of converting the Args to an ipld.Node.
func (*Builder) MustBuildIPLD ¶
func (b *Builder) MustBuildIPLD() ipld.Node
MustBuildIPLD is the same as BuildIPLD except it panics if an error occurs.
type ReadOnly ¶
type ReadOnly struct {
// contains filtered or unexported fields
}