diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-23 00:24:03 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-23 00:24:03 +0900 |
| commit | 54308f79d206f89807aba3bc998fc770d01efed1 (patch) | |
| tree | 26d47a3fcc00ef01301b5d58e0e7a6374733dc28 /command/builder.go | |
| parent | dfa3217037d8c24181be24484892ecb950a2a5ba (diff) | |
command: expose command with direct handling
This exposes flag set on commands with direct handling.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'command/builder.go')
| -rw-r--r-- | command/builder.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/command/builder.go b/command/builder.go index ae49c56e..5c9b4de9 100644 --- a/command/builder.go +++ b/command/builder.go @@ -31,6 +31,11 @@ func newNode(output io.Writer, logf LogFunc, name, usage string) *node { } func (n *node) Command(name, usage string, f HandlerFunc) Node { + n.NewCommand(name, usage, f) + return n +} + +func (n *node) NewCommand(name, usage string, f HandlerFunc) Flag[Node] { if f == nil { panic("invalid handler") } @@ -43,7 +48,7 @@ func (n *node) Command(name, usage string, f HandlerFunc) Node { if !n.adopt(s) { panic("attempted to initialise subcommand with non-unique name") } - return n + return s } func (n *node) New(name, usage string) Node { |
