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

View File

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