Merge pull request #278 from Areson/ioberst-global-help-options

Fix Missing Global Options
This commit is contained in:
Alex Flint 2025-03-07 17:08:54 -05:00 committed by GitHub
commit 7155e7e986
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -285,6 +285,13 @@ func NewParser(config Config, dests ...interface{}) (*Parser, error) {
}
}
// Set the parent of the subcommands to be the top-level command
// to make sure that global options work when there is more than one
// dest supplied.
for _, subcommand := range p.cmd.subcommands {
subcommand.parent = p.cmd
}
return &p, nil
}