mirror of
https://github.com/monero-project/monero.git
synced 2025-06-21 03:04:12 -04:00
simplewallet: reject invalid argument for boolean parameter
This commit is contained in:
parent
af448d3883
commit
105425b7f6
3 changed files with 95 additions and 26 deletions
|
@ -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"};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue