Skip to content

Commit 3a251e8

Browse files
authored
allow sub-command mounting (#2)
1 parent c8b9ef6 commit 3a251e8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

command_options.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ func AddSubCmd(name, description string, options ...option.Option[*Command]) opt
4040
return nil, err
4141
}
4242

43+
return MountSubCmd(subCommand).Apply(command)
44+
}
45+
}
46+
47+
// MountSubCmd mounds an existing *Command as a sub-command.
48+
func MountSubCmd(subCommand *Command) option.Func[*Command] {
49+
return func(command *Command) (*Command, error) {
4350
subCommand.parent = command
4451
command.subCommands = append(command.subCommands, subCommand)
4552
return command, nil

0 commit comments

Comments
 (0)