mirror of
https://github.com/CLIUtils/CLI11.git
synced 2026-01-19 04:52:08 +00:00
Module testing (#1255)
Address issue #1254 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
This commit is contained in:
@@ -175,4 +175,11 @@
|
||||
#else
|
||||
#define CLI11_INLINE inline
|
||||
#endif
|
||||
|
||||
/** Module inline to support module operations**/
|
||||
#if defined CLI11_CPP17
|
||||
#define CLI11_MODULE_INLINE inline
|
||||
#else
|
||||
#define CLI11_MODULE_INLINE static
|
||||
#endif
|
||||
// [CLI11:macros_hpp:end]
|
||||
|
||||
@@ -45,7 +45,7 @@ using enums::operator<<;
|
||||
namespace detail {
|
||||
/// a constant defining an expected max vector size defined to be a big number that could be multiplied by 4 and not
|
||||
/// produce overflow for some expected uses
|
||||
constexpr int expected_max_vector_size{1 << 29};
|
||||
CLI11_MODULE_INLINE constexpr int expected_max_vector_size{1 << 29};
|
||||
// Based on http://stackoverflow.com/questions/236129/split-a-string-in-c
|
||||
/// Split a string by a delim
|
||||
CLI11_INLINE std::vector<std::string> split(const std::string &s, char delim);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace detail {
|
||||
enum class enabler : std::uint8_t {};
|
||||
|
||||
/// An instance to use in EnableIf
|
||||
constexpr enabler dummy = {};
|
||||
CLI11_MODULE_INLINE constexpr enabler dummy = {};
|
||||
} // namespace detail
|
||||
|
||||
/// A copy of enable_if_t from C++14, compatible with C++11.
|
||||
|
||||
@@ -1272,15 +1272,18 @@ CLI11_INLINE void App::_process_help_flags(CallbackPriority priority, bool trigg
|
||||
const Option *help_ptr = get_help_ptr();
|
||||
const Option *help_all_ptr = get_help_all_ptr();
|
||||
|
||||
if(help_ptr != nullptr && help_ptr->count() > 0 && help_ptr->get_callback_priority() == priority)
|
||||
if(help_ptr != nullptr && help_ptr->count() > 0 && help_ptr->get_callback_priority() == priority) {
|
||||
trigger_help = true;
|
||||
if(help_all_ptr != nullptr && help_all_ptr->count() > 0 && help_all_ptr->get_callback_priority() == priority)
|
||||
}
|
||||
if(help_all_ptr != nullptr && help_all_ptr->count() > 0 && help_all_ptr->get_callback_priority() == priority) {
|
||||
trigger_all_help = true;
|
||||
}
|
||||
|
||||
// If there were parsed subcommands, call those. First subcommand wins if there are multiple ones.
|
||||
if(!parsed_subcommands_.empty()) {
|
||||
for(const App *sub : parsed_subcommands_)
|
||||
for(const App *sub : parsed_subcommands_) {
|
||||
sub->_process_help_flags(priority, trigger_help, trigger_all_help);
|
||||
}
|
||||
|
||||
// Only the final subcommand should call for help. All help wins over help.
|
||||
} else if(trigger_all_help) {
|
||||
|
||||
@@ -185,10 +185,10 @@ find_member(std::string name, const std::vector<std::string> names, bool ignore_
|
||||
return (it != std::end(names)) ? (it - std::begin(names)) : (-1);
|
||||
}
|
||||
|
||||
static const std::string escapedChars("\b\t\n\f\r\"\\");
|
||||
static const std::string escapedCharsCode("btnfr\"\\");
|
||||
static const std::string bracketChars{"\"'`[(<{"};
|
||||
static const std::string matchBracketChars("\"'`])>}");
|
||||
CLI11_MODULE_INLINE const std::string &escapedChars("\b\t\n\f\r\"\\");
|
||||
CLI11_MODULE_INLINE const std::string &escapedCharsCode("btnfr\"\\");
|
||||
CLI11_MODULE_INLINE const std::string &bracketChars("\"'`[(<{");
|
||||
CLI11_MODULE_INLINE const std::string &matchBracketChars("\"'`])>}");
|
||||
|
||||
CLI11_INLINE bool has_escapable_character(const std::string &str) {
|
||||
return (str.find_first_of(escapedChars) != std::string::npos);
|
||||
|
||||
Reference in New Issue
Block a user