Skip to content

Commit

Permalink
Remove member
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Feb 8, 2024
1 parent 8a33945 commit 1d50ee1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions include/sharg/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,6 @@ class parser
//!\brief Keeps track of whether the parse function has been called already.
bool parse_was_called{false};

//!\brief Keeps track of whether the init function has been called already.
bool init_was_called{false};

//!\brief Keeps track of whether the user has added a positional list option to check if this was the very last.
bool has_positional_list_option{false};

Expand Down Expand Up @@ -748,7 +745,7 @@ class parser
//!\brief List of option/flag identifiers that are already used.
std::set<std::string> used_option_ids{"h", "hh", "help", "advanced-help", "export-help", "version", "copyright"};

//!\brief The command line arguments.
//!\brief The command line arguments that will be passed to the format.
std::vector<std::string> cmd_arguments{};

//!\brief The original command line arguments.
Expand Down Expand Up @@ -788,15 +785,18 @@ class parser
{
assert(!original_arguments.empty());

if (init_was_called)
{
cmd_arguments.clear();
}
else
{
// If init() is called multiple times (via add_subcommands):
// * We need to clear cmd_arguments. They will be parsed again.
// * We need to handle executable_name:
// * If it is empty:
// * We are in the top level parser, or
// * We are constructing a subparser: make_unique<parser> -> constructor -> init
// * If it is not empty, we arrived here through a call to add_subcommands, in which case we already
// appended the subcommand to the executable_name.
cmd_arguments.clear();

if (executable_name.empty())
executable_name.emplace_back(original_arguments[0]);
init_was_called = true;
}

bool special_format_was_set{false};

Expand Down

0 comments on commit 1d50ee1

Please sign in to comment.