diff --git a/include/blt/parse/argparse.h b/include/blt/parse/argparse.h index 73f30c3..fecb0cc 100644 --- a/include/blt/parse/argparse.h +++ b/include/blt/parse/argparse.h @@ -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) diff --git a/src/blt/parse/argparse.cpp b/src/blt/parse/argparse.cpp index 39d8d5d..09ba022 100644 --- a/src/blt/parse/argparse.cpp +++ b/src/blt/parse/argparse.cpp @@ -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; diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 371b801..2e050b6 100755 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -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 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++) {