rename help disabler to SUBCOMMAND action type

v1
Brett 2023-09-16 17:40:35 -04:00
parent 9db6dd8456
commit 02a1dc1a8c
3 changed files with 13 additions and 17 deletions

View File

@ -34,7 +34,8 @@ namespace blt
COUNT,
HELP,
VERSION,
EXTEND
EXTEND,
SUBCOMMAND
};
class arg_vector_t
@ -129,7 +130,6 @@ namespace blt
std::string a_version{};
std::string a_metavar{};
bool a_required = true;
bool a_disable_help = false;
};
class arg_builder
@ -182,12 +182,6 @@ namespace blt
return *this;
}
inline arg_builder& disableHelp()
{
properties.a_disable_help = true;
return *this;
}
inline arg_builder& setHelp(const std::string& help)
{
properties.a_help = help;
@ -342,7 +336,7 @@ namespace blt
void handleFlag(arg_tokenizer& tokenizer, const std::string& flag, const arg_properties_t* properties);
std::string getProgramName() const
[[nodiscard]] std::string getProgramName() const
{
return use_full_name ? loaded_args.program_name : filename(loaded_args.program_name);
}

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

View File

@ -82,7 +82,8 @@ namespace blt
return flag;
}
std::string arg_vector_t::getArgName() const {
std::string arg_vector_t::getArgName() const
{
if (name.empty())
return getFirstFullFlag();
return name;
@ -252,8 +253,6 @@ namespace blt
if (!found)
{
const auto& arg_property = user_args.name_associations[index];
if (arg_property->a_disable_help)
help_disabled = true;
loaded_args.data[arg_property->a_dest] = tokenizer.get();
loaded_args.found_args.insert(arg_property->a_dest);
}
@ -320,9 +319,6 @@ namespace blt
loaded_args.found_args.insert(dest);
if (properties->a_disable_help)
help_disabled = true;
switch (properties->a_action)
{
case arg_action_t::HELP:
@ -363,6 +359,11 @@ namespace blt
data = get<int32_t>(data) + 1;
break;
}
case arg_action_t::SUBCOMMAND:
{
help_disabled = true;
break;
}
case arg_action_t::EXTEND:
{
@ -464,7 +465,7 @@ namespace blt
if (takesArgs(named_arg) && !loaded_args.contains(named_arg->a_dest))
{
printUsage();
std::cout << "postional argument '" << named_arg->a_flags.name << "' expected " << named_arg->a_nargs.args << " argument"
std::cout << "positional argument '" << named_arg->a_flags.name << "' expected " << named_arg->a_nargs.args << " argument"
<< (named_arg->a_nargs.args > 1 ? "s!" : "!") << std::endl;
std::exit(0);
}
@ -485,6 +486,7 @@ namespace blt
case arg_action_t::COUNT:
case arg_action_t::HELP:
case arg_action_t::VERSION:
case arg_action_t::SUBCOMMAND:
return false;
case arg_action_t::STORE:
case arg_action_t::APPEND: