Skip to content

Commit a1a65e2

Browse files
committed
Fix Missing Global Options
1 parent f218789 commit a1a65e2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

parse.go

+7
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ func NewParser(config Config, dests ...interface{}) (*Parser, error) {
285285
}
286286
}
287287

288+
// Set the parent of the subcommands to be the top-level command
289+
// to make sure that global options work when there is more than one
290+
// dest supplied.
291+
for _, subcommand := range p.cmd.subcommands {
292+
subcommand.parent = p.cmd
293+
}
294+
288295
return &p, nil
289296
}
290297

0 commit comments

Comments
 (0)