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/command.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/command.go')
| -rw-r--r-- | command/command.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/command/command.go b/command/command.go index 55f0eade..d0cab36a 100644 --- a/command/command.go +++ b/command/command.go @@ -19,6 +19,11 @@ type ( Define(b *strings.Builder, set *flag.FlagSet, p any, name, usage string) } + Flag[T any] interface { + // Flag defines a generic flag type in Node's flag set. + Flag(p any, name string, value FlagDefiner, usage string) T + } + Command interface { Parse(arguments []string) error baseNode[Command] @@ -28,10 +33,12 @@ type ( baseNode[T any] interface { // Command appends a subcommand with direct command handling. Command(name, usage string, f HandlerFunc) T - // Flag defines a generic flag type in Node's flag set. - Flag(p any, name string, value FlagDefiner, usage string) T // New returns a new subcommand tree. New(name, usage string) (sub Node) + // NewCommand returns a new subcommand with direct command handling. + NewCommand(name, usage string, f HandlerFunc) (sub Flag[Node]) + + Flag[T] } ) |
