rename internal fields away from help to subcommand

v1
Brett 2023-09-16 17:50:37 -04:00
parent 45aeb13dd8
commit 7a07f4a729
3 changed files with 11 additions and 11 deletions

View File

@ -307,9 +307,9 @@ namespace blt
} }
} loaded_args; } loaded_args;
bool help_disabled = false; bool subcommand_found = false;
bool use_full_name = false; bool use_full_name = false;
std::string help_inclusion; std::string subcommand_name;
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)
{ {
help_inclusion = std::move(str); subcommand_name = std::move(str);
} }
static std::string filename(const std::string& path); static std::string filename(const std::string& path);

@ -1 +1 @@
Subproject commit 77cab8192a879e5d27188f97e8f2080dd7e36ca8 Subproject commit 93201da2ba5a6aba0a6e57ada64973555629b3e3

View File

@ -362,7 +362,7 @@ namespace blt
case arg_action_t::SUBCOMMAND: case arg_action_t::SUBCOMMAND:
{ {
loaded_args[flag] = true; loaded_args[flag] = true;
help_disabled = true; subcommand_found = true;
break; break;
} }
case arg_action_t::EXTEND: case arg_action_t::EXTEND:
@ -414,10 +414,10 @@ namespace blt
loaded_args.program_name = tokenizer.get(); loaded_args.program_name = tokenizer.get();
tokenizer.advance(); tokenizer.advance();
if (!help_inclusion.empty()) if (!subcommand_name.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() != help_inclusion) while (tokenizer.hasCurrent() && tokenizer.get() != subcommand_name)
tokenizer.advance(); tokenizer.advance();
tokenizer.advance(); tokenizer.advance();
} }
@ -426,7 +426,7 @@ 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 (help_disabled) if (subcommand_found)
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 (help_disabled) if (subcommand_found)
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 (help_disabled) if (subcommand_found)
return; return;
std::string usage = "Usage: " + getProgramName() + " " + help_inclusion + " "; std::string usage = "Usage: " + getProgramName() + " " + subcommand_name + " ";
std::cout << usage; std::cout << usage;
size_t current_line_length = 0; size_t current_line_length = 0;