diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-11-14 15:04:15 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-11-14 15:04:15 +0200 |
commit | f4fded6fcf506da08b74988003ebf5f06a275972 (patch) | |
tree | 895c79b0c34eebc7d4aa8d5a70518ab8bb2e1da7 /src/common | |
parent | Merge pull request #2682 (diff) | |
parent | simplewallet: reject invalid argument for boolean parameter (diff) | |
download | monero-f4fded6fcf506da08b74988003ebf5f06a275972.tar.xz |
Merge pull request #2683
105425b7 simplewallet: reject invalid argument for boolean parameter (stoffu)
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/command_line.cpp | 14 | ||||
-rw-r--r-- | src/common/command_line.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index 666b3267f..d4a28fc85 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -78,6 +78,20 @@ namespace command_line return false; } + bool is_no(const std::string& str) + { + if (str == "n" || str == "N") + return true; + + boost::algorithm::is_iequal ignore_case{}; + if (boost::algorithm::equals("no", str, ignore_case)) + return true; + if (boost::algorithm::equals(command_line::tr("no"), str, ignore_case)) + return true; + + return false; + } + const arg_descriptor<bool> arg_help = {"help", "Produce help message"}; const arg_descriptor<bool> arg_version = {"version", "Output version information"}; const arg_descriptor<std::string> arg_data_dir = {"data-dir", "Specify data directory"}; diff --git a/src/common/command_line.h b/src/common/command_line.h index 04fd70be5..bfc8b19c6 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -45,6 +45,8 @@ namespace command_line //! \return True if `str` is `is_iequal("y" || "yes" || `tr("yes"))`. bool is_yes(const std::string& str); + //! \return True if `str` is `is_iequal("n" || "no" || `tr("no"))`. + bool is_no(const std::string& str); template<typename T, bool required = false> struct arg_descriptor; |