Compare commits

..

No commits in common. "7a07f4a72922de6fdb107887902a3efa4266ed16" and "02a1dc1a8ce06359c0fd949ce05d2561025d8bde" have entirely different histories.

2 changed files with 11 additions and 11 deletions

View File

@ -307,9 +307,9 @@ namespace blt
}
} loaded_args;
bool subcommand_found = false;
bool help_disabled = false;
bool use_full_name = false;
std::string subcommand_name;
std::string help_inclusion;
private:
static std::string getMetavar(const arg_properties_t* const& arg);
@ -430,7 +430,7 @@ namespace blt
inline void setHelpExtras(std::string str)
{
subcommand_name = std::move(str);
help_inclusion = std::move(str);
}
static std::string filename(const std::string& path);

View File

@ -361,8 +361,7 @@ namespace blt
}
case arg_action_t::SUBCOMMAND:
{
loaded_args[flag] = true;
subcommand_found = true;
help_disabled = true;
break;
}
case arg_action_t::EXTEND:
@ -414,10 +413,10 @@ namespace blt
loaded_args.program_name = tokenizer.get();
tokenizer.advance();
if (!subcommand_name.empty())
if (!help_inclusion.empty())
{
// advance the tokenizer to post grouped args allowing for flags
while (tokenizer.hasCurrent() && tokenizer.get() != subcommand_name)
while (tokenizer.hasCurrent() && tokenizer.get() != help_inclusion)
tokenizer.advance();
tokenizer.advance();
}
@ -426,7 +425,8 @@ namespace blt
while (tokenizer.hasCurrent())
{
// if we find an arg which disables help (basically a grouping flag) then we should stop processing args
if (subcommand_found)
// TODO: rename this to be more descriptive
if (help_disabled)
break;
if (tokenizer.isFlag())
@ -498,7 +498,7 @@ namespace blt
void arg_parse::printHelp() const
{
if (subcommand_found)
if (help_disabled)
return;
if (!user_args.prefix.empty())
{
@ -558,9 +558,9 @@ namespace blt
void arg_parse::printUsage() const
{
if (subcommand_found)
if (help_disabled)
return;
std::string usage = "Usage: " + getProgramName() + " " + subcommand_name + " ";
std::string usage = "Usage: " + getProgramName() + " " + help_inclusion + " ";
std::cout << usage;
size_t current_line_length = 0;