Documentation
¶
Overview ¶
Package cli implements the matter command tree using cobra.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute() error
Execute runs the root command. It is the main entry point called from main.go.
Before handing off to cobra, it scans os.Args for an @target token (e.g. "@1" or "@1/2") and extracts it so that cobra never sees it. The parsed target is stored in extractedTarget and applied during PersistentPreRunE via resolveTarget().
Cobra's built-in completion subcommands (__complete, __completeNoDesc) get special treatment: the final arg is the partial word being completed (toComplete) and must be preserved verbatim so the completion handler can see it as the current token. @targets in the *committed* args before toComplete are still extracted so cobra's command traversal can resolve subcommands past the @target (e.g. for "matter @1/1 OnOff <TAB>" the "@1/1" would otherwise stop traversal at root and OnOff's completion function would never run).
func IsTargetArg ¶
IsTargetArg reports whether the given argument looks like a @target token.
Types ¶
type Target ¶
type Target struct {
NodeID uint64
Endpoint uint16
EndpointSet bool
// ExplicitEndpoint is true when the endpoint was specified with a "/"
// separator by the user (e.g. @node/1) or set explicitly via a sticky
// default. It is false when the endpoint was not specified at all. Only
// used for completion filtering — command execution behaviour is
// unaffected.
ExplicitEndpoint bool
}
Target represents a resolved device target consisting of a node ID and an optional endpoint. When Endpoint is 0 and EndpointSet is false, the caller should treat the endpoint as unspecified (distinct from explicitly targeting endpoint 0).
func ExtractTargetFromArgs ¶
ExtractTargetFromArgs scans the argument list for a @target token, parses it, removes it from the args, and returns the modified args along with the parsed target (which may be nil if no @target was found).
If a @target token is found but cannot be parsed, it is left in the args so that cobra produces a normal "unknown command" error rather than silently swallowing a typo.
func ParseTarget ¶
ParseTarget parses a target string in the format "@node[/endpoint]". The node part must be a numeric node ID; device aliases are not accepted. The endpoint part is optional and defaults to unset.
Examples:
"@1" → node 1, endpoint unset "@1/2" → node 1, endpoint 2
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package completion provides dynamic shell completion helpers for matter-cli.
|
Package completion provides dynamic shell completion helpers for matter-cli. |
|
Package output provides output formatting for matter-cli commands.
|
Package output provides output formatting for matter-cli commands. |