Skip to content

Commit f759d84

Browse files
committed
feat: add Parent() accessor to Command (fixes #2372)
1 parent c5f123b commit f759d84

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

command.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ func (cmd *Command) argsWithDefaultCommand(oldArgs Args) Args {
337337
}
338338

339339
// Root returns the Command at the root of the graph
340+
// Parent returns the parent command, or nil if this is the root command.
341+
func (cmd *Command) Parent() *Command {
342+
return cmd.parent
343+
}
344+
340345
func (cmd *Command) Root() *Command {
341346
if cmd.parent == nil {
342347
return cmd

0 commit comments

Comments
 (0)