v1
Brett 2023-08-10 02:30:09 -04:00
parent a44590c195
commit e68d7aa87f
3 changed files with 4 additions and 18 deletions

View File

@ -291,7 +291,6 @@ namespace blt
} loaded_args;
private:
static std::string filename(const std::string& path);
static std::string getMetavar(const arg_properties_t* const& arg);
static std::string getFlagHelp(const arg_properties_t* const& arg);
@ -363,6 +362,8 @@ namespace blt
user_args.max_line_length = size;
}
static std::string filename(const std::string& path);
~arg_parse()
{
for (auto* p : user_args.arg_properties_storage)

View File

@ -495,7 +495,7 @@ namespace blt
void arg_parse::printUsage() const
{
std::string usage = "Usage: " + loaded_args.program_name + " ";
std::string usage = "Usage: " + filename(loaded_args.program_name) + " ";
std::cout << usage;
size_t current_line_length = 0;

View File

@ -69,25 +69,10 @@ int (*func_func_in)(int) = &test_as_func;
int main(int argc, const char** argv) {
blt::arg_parse parser;
parser.addArgument(blt::arg_builder({"--poo", "-p"}).build());
parser.addArgument(blt::arg_builder("--foo").setAction(blt::arg_action_t::STORE_TRUE).setDefault(false).build());
parser.addArgument(blt::arg_builder({"--goo", "-g"}).build());
parser.addArgument(blt::arg_builder({"--oop", "-o"}).build());
parser.addArgument(blt::arg_builder("Sexy_pos").setHelp("I am helpful!").build());
parser.addArgument(blt::arg_builder({"-c", "--no-color"}).setAction(blt::arg_action_t::STORE_TRUE).build());
auto args = parser.parse_args(argc, argv);
std::vector<std::string> superArgs {
"BLT_TESTS",
"Sexy",
"-p", "I have poop",
"--help"
};
auto args2 = parser.parse_args(superArgs);
for (const auto& a : args2.data){
BLT_TRACE("['%s' = '%s']", a.first.c_str(), blt::to_string(a.second).c_str());
}
BLT_TRACE(args2.program_name);
//
// if (argc > 1 && std::string(argv[1]) == "--no_color") {
// for (int i = (int)blt::logging::log_level::NONE; i < (int)blt::logging::log_level::FATAL; i++) {