diff --git a/include/blt/parse/argparse.h b/include/blt/parse/argparse.h index ed1dc15..54d67bc 100755 --- a/include/blt/parse/argparse.h +++ b/include/blt/parse/argparse.h @@ -50,19 +50,27 @@ namespace blt void validateFlags(); public: - arg_vector_t(std::vector flags): flags(std::move(flags)) + explicit arg_vector_t(std::vector flags): flags(std::move(flags)) { validateFlags(); } - arg_vector_t(std::initializer_list flags): flags(flags) + arg_vector_t(std::initializer_list f): flags(f) { + if (flags.size() == 1) { + if (!blt::string::starts_with(flags[0], '-')) + { + name = flags[0]; + flags.clear(); + return; + } + } validateFlags(); } - arg_vector_t(const char* str); + explicit arg_vector_t(const char* str); - arg_vector_t(const std::string& str); + explicit arg_vector_t(const std::string& str); [[nodiscard]] inline bool isFlag() const { @@ -135,6 +143,9 @@ namespace blt explicit arg_properties_t(arg_vector_t flags): a_flags(std::move(flags)) {} + + explicit arg_properties_t(const std::string& pos_arg): a_flags(pos_arg) + {} }; class arg_builder @@ -145,6 +156,9 @@ namespace blt explicit arg_builder(const arg_vector_t& flags): properties(flags) {} + explicit arg_builder(const std::string& pos_arg): properties(pos_arg) + {} + arg_builder(const std::initializer_list& flags): properties(flags) {} diff --git a/src/blt/parse/argparse.cpp b/src/blt/parse/argparse.cpp index 75e5572..54d6275 100755 --- a/src/blt/parse/argparse.cpp +++ b/src/blt/parse/argparse.cpp @@ -54,7 +54,7 @@ namespace blt arg_vector_t::arg_vector_t(const char* str) { std::string as_string(str); - if (as_string.starts_with('-')) + if (blt::string::starts_with(str, '-')) flags.emplace_back(as_string); else name = as_string; @@ -62,7 +62,7 @@ namespace blt arg_vector_t::arg_vector_t(const std::string& str) { - if (str.starts_with('-')) + if (blt::string::starts_with(str, '-')) flags.emplace_back(str); else name = str;