Documentation
¶
Index ¶
- func NewRegexNode(fn ValueFunc) func(MetaData) Node
- func SliceToString(edges []string) string
- type CLI
- type ExecNode
- type IntNode
- type MetaData
- type NOPNode
- func (node *NOPNode) Add(addFn func(meta MetaData) Node, keys ...string) Node
- func (node *NOPNode) AddToken(v string)
- func (node *NOPNode) Ctx() MetaData
- func (node *NOPNode) Exec(cmd []string) error
- func (node *NOPNode) Func(v interface{}, token string) error
- func (node *NOPNode) Nexts() map[Node][]string
- func (node *NOPNode) Print(tree treeprint.Tree)
- func (node *NOPNode) Token() []string
- func (node *NOPNode) Values() map[string]interface{}
- func (node *NOPNode) WithExec(fn NodeFunc, keys ...string) Node
- func (node *NOPNode) WithInt(fn ValueFunc) Node
- func (node *NOPNode) WithKeys(fn ValueFunc, keys ...string) Node
- func (node *NOPNode) WithNOP(keys ...string) Node
- func (node *NOPNode) WithRegex(fn func(MetaData) error, patterns ...string) Node
- func (node *NOPNode) WithStr(fn ValueFunc) Node
- type Node
- type NodeFunc
- type RegexNode
- func (node *RegexNode) Add(addFn func(MetaData) Node, patterns ...string) Node
- func (node *RegexNode) AddToken(v string)
- func (node *RegexNode) Ctx() MetaData
- func (node *RegexNode) Exec(cmd []string) error
- func (node *RegexNode) Func(v interface{}, token string) error
- func (node *RegexNode) Nexts() map[Node][]string
- func (node *RegexNode) Print(tree treeprint.Tree)
- func (node *RegexNode) Token() []string
- func (node *RegexNode) Values() map[string]interface{}
- func (node *RegexNode) WithExec(fn NodeFunc, keys ...string) Node
- func (node *RegexNode) WithInt(fn ValueFunc) Node
- func (node *RegexNode) WithKeys(fn ValueFunc, keys ...string) Node
- func (node *RegexNode) WithNOP(keys ...string) Node
- func (node *RegexNode) WithRegex(fn func(MetaData) error, patterns ...string) Node
- func (node *RegexNode) WithStr(fn ValueFunc) Node
- type StrNode
- type ValueFunc
- type ValueNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRegexNode ¶
func SliceToString ¶
Types ¶
type CLI ¶
type NOPNode ¶
type NOPNode struct {
// contains filtered or unexported fields
}
func (*NOPNode) Func ¶
Func on NOPNode does nothing since NOPNodes don't have any ValueFunc/NodeFunc mapped to it
type Node ¶
type Node interface {
// WithNOP creates and adds a NOPNode
// to the command which only exists so that
// a sentence is grammarly correct. It has no
// functionality, but to allow clean and correct english/german/world
// sentences.
WithNOP(keys ...string) Node
// WithKeys returns a Node which ValueFunc will be executed when the
// Node is reached in the trie. This allows to add custom data to
// the overall context of the command.
WithKeys(fn ValueFunc, keys ...string) Node
// WithRegex returns a Node which key is a regex.
// The node will allow to match every token which
// matches the pattern.
// The ValueFunc can be used to add the value with a custom key and
// will be executed if the Node is reached in the trie.
WithRegex(fn func(meta MetaData) error, patterns ...string) Node
// WithInt returns a Node which does not specifiys a key.
// However, an IntNode matches every token which can be parsed as
// and int64 and adds the value to the overall data.
// The ValueFunc can be used to add the value with a custom key and
// will be executed if the Node is reached in the trie.
WithInt(fn ValueFunc) Node
// WithStr returns a Node which does not specifiys a key.
// However, an StrNode matches EVERY next token and adds
// the value to the overall data.
// The ValueFunc can be used to add the value with a custom key and
// will be executed if the Node is reached in the trie.
WithStr(fn ValueFunc) Node
// WithExec adds a ExecNode to the cmd which when reached will execute the
// node's NodeFunc. The NodeFunc gets the full context of
// the run a CMD with all the stored data.
// Tipically this node would be used as the last node of an CMD
WithExec(fn NodeFunc, keys ...string) Node
// Values returns the current state of the Cmd's data
Values() map[string]interface{}
AddToken(v string)
Token() []string
Ctx() MetaData
// Nexts returns all nodes which can be reached from a node
// and its edges over which the node can be reached
Nexts() map[Node][]string
// Func executes the mapped ValueFunc or NodeFunc on a node
// NOPNodes don't have any function, a call to NOPNode.Func() will
// to nothing
Func(v interface{}, token string) error
// Print appends the treeprint.Tree with the node's keys
// in the form of [key | key]. If the node has nexts Print
// will be called on each next node.
Print(tree treeprint.Tree)
Exec(cmd []string) error
}
func NewNOPNode ¶
type NodeFunc ¶
NodeFunc is a function which recevied the current Node as an argument allowing the caller to perform a veraity of action. Propably only useful for the "last" node to execute the final command, while having access to all the stored data
type RegexNode ¶
type RegexNode struct {
// contains filtered or unexported fields
}
func (*RegexNode) Func ¶
Func on RegexNode does nothing since RegexNodes don't have any ValueFunc/NodeFunc mapped to it
Click to show internal directories.
Click to hide internal directories.

