aboutsummaryrefslogtreecommitdiffhomepage
path: root/command
diff options
context:
space:
mode:
Diffstat (limited to 'command')
-rw-r--r--command/node.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/command/node.go b/command/node.go
new file mode 100644
index 00000000..9ed21499
--- /dev/null
+++ b/command/node.go
@@ -0,0 +1,36 @@
+package command
+
+import (
+ "flag"
+ "io"
+)
+
+type node struct {
+ child, next *node
+ name, usage string
+
+ out io.Writer
+ logf LogFunc
+
+ f HandlerFunc
+ set *flag.FlagSet
+}
+
+func (n *node) adopt(v *node) bool {
+ if n.child != nil {
+ return n.child.append(v)
+ }
+ n.child = v
+ return true
+}
+
+func (n *node) append(v *node) bool {
+ if n.name == v.name {
+ return false
+ }
+ if n.next != nil {
+ return n.next.append(v)
+ }
+ n.next = v
+ return true
+}