File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -793,19 +793,26 @@ class parser
793793 {
794794 assert (!original_arguments.empty ());
795795
796- // If init() is called multiple times (via add_subcommands):
796+ // Start: If init() is called multiple times (via add_subcommands).
797+
798+ // * If sub_parser is set, nothing needs to be done. There can only ever be one subparser.
799+ if (sub_parser)
800+ return ;
801+
797802 // * We need to clear cmd_arguments. They will be parsed again.
803+ cmd_arguments.clear ();
804+
798805 // * We need to handle executable_name:
799806 // * If it is empty:
800807 // * We are in the top level parser, or
801808 // * We are constructing a subparser: make_unique<parser> -> constructor -> init
802809 // * If it is not empty, we arrived here through a call to add_subcommands, in which case we already
803810 // appended the subcommand to the executable_name.
804- cmd_arguments.clear ();
805-
806811 if (executable_name.empty ())
807812 executable_name.emplace_back (original_arguments[0 ]);
808813
814+ // End: If init() is called multiple times (via add_subcommands).
815+
809816 bool special_format_was_set{false };
810817
811818 // Helper function for going to the next argument. This makes it more obvious that we are
You can’t perform that action at this time.
0 commit comments