simplewallet.sweep_all: show usage when parsing fails

This commit is contained in:
stoffu 2018-06-27 20:33:26 +09:00
parent ffab67004c
commit 13851b28c7
No known key found for this signature in database
GPG Key ID: 41DAB8343A9EC012

View File

@ -4964,10 +4964,14 @@ bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &args_) bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &args_)
{ {
// sweep_all [index=<N1>[,<N2>,...]] [<ring_size>] <address> [<payment_id>] auto print_usage = [below]()
{
fail_msg_writer() << boost::format(tr("usage: %s [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id>]")) % (below ? "sweep_below" : "sweep_all");
};
if (args_.size() == 0) if (args_.size() == 0)
{ {
fail_msg_writer() << tr("No address given"); fail_msg_writer() << tr("No address given");
print_usage();
return true; return true;
} }
@ -4981,7 +4985,10 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
if (local_args.size() > 0 && local_args[0].substr(0, 6) == "index=") if (local_args.size() > 0 && local_args[0].substr(0, 6) == "index=")
{ {
if (!parse_subaddress_indices(local_args[0], subaddr_indices)) if (!parse_subaddress_indices(local_args[0], subaddr_indices))
{
print_usage();
return true; return true;
}
local_args.erase(local_args.begin()); local_args.erase(local_args.begin());
} }
@ -5049,6 +5056,7 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
if(!r && local_args.size() == 3) if(!r && local_args.size() == 3)
{ {
fail_msg_writer() << tr("payment id has invalid format, expected 16 or 64 character hex string: ") << payment_id_str; fail_msg_writer() << tr("payment id has invalid format, expected 16 or 64 character hex string: ") << payment_id_str;
print_usage();
return true; return true;
} }
if (payment_id_seen) if (payment_id_seen)
@ -5059,6 +5067,7 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
if (!cryptonote::get_account_address_from_str_or_url(info, m_wallet->nettype(), local_args[0], oa_prompter)) if (!cryptonote::get_account_address_from_str_or_url(info, m_wallet->nettype(), local_args[0], oa_prompter))
{ {
fail_msg_writer() << tr("failed to parse address"); fail_msg_writer() << tr("failed to parse address");
print_usage();
return true; return true;
} }