From a1a65e29cfa91c716eceabdca0707d18a76b26ff Mon Sep 17 00:00:00 2001 From: Ian Oberst Date: Tue, 11 Feb 2025 09:26:24 -0800 Subject: [PATCH] Fix Missing Global Options --- parse.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/parse.go b/parse.go index 3a08b10..bf6784a 100644 --- a/parse.go +++ b/parse.go @@ -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 }