diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-08-07 18:57:01 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-08-07 18:57:01 +0900 |
| commit | b37c1d899349fef9e7af38940ae0c2d507c433a9 (patch) | |
| tree | 5bc20683560d7fcd571d4587487bcf8575a4cf0b /command/node.go | |
| parent | 6a7f124debbeb4fb36be2b5373517f5677a635d4 (diff) | |
command: use NUL for magic usage string
This change also improves documentation.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'command/node.go')
| -rw-r--r-- | command/node.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/command/node.go b/command/node.go index 4d09c975..b6f84bf8 100644 --- a/command/node.go +++ b/command/node.go @@ -6,6 +6,7 @@ import ( "strings" ) +// A node represents a command. type node struct { child, next *node name, usage string @@ -13,13 +14,16 @@ type node struct { out io.Writer logf LogFunc + // Names of commands preceding node. prefix []string + // Short user-facing representations of flags received by node. suffix strings.Builder f HandlerFunc set *flag.FlagSet } +// adopt adds v as the last child of n. func (n *node) adopt(v *node) bool { if n.child != nil { return n.child.append(v) @@ -28,6 +32,7 @@ func (n *node) adopt(v *node) bool { return true } +// append adds v as the last sibling of n. func (n *node) append(v *node) bool { if n.name == v.name { return false |
