simplewallet: noob-friendly help menu

This commit is contained in:
wowario 2019-11-13 10:17:45 +03:00
parent fe3f6a3e6b
commit 67b4a19edf
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111
4 changed files with 48 additions and 14 deletions

View File

@ -1639,8 +1639,9 @@ namespace cryptonote
<< "You can set the level of process detailization through \"set_log <level|categories>\" command," << ENDL << "You can set the level of process detailization through \"set_log <level|categories>\" command," << ENDL
<< "where <level> is between 0 (no details) and 4 (very verbose), or custom category based levels (eg, *:WARNING)." << ENDL << "where <level> is between 0 (no details) and 4 (very verbose), or custom category based levels (eg, *:WARNING)." << ENDL
<< ENDL << ENDL
<< "Use the \"help\" command to see the list of available commands." << ENDL << "Use the \"help\" command to see a simplified list of available commands." << ENDL
<< "Use \"help <command>\" to see a command's documentation." << ENDL << "Use the \"help_advanced\" command to see an advanced list of available commands." << ENDL
<< "Use \"help_advanced <command>\" to see a command's documentation." << ENDL
<< "**********************************************************************" << ENDL); << "**********************************************************************" << ENDL);
m_starter_message_showed = true; m_starter_message_showed = true;
} }

View File

@ -2181,7 +2181,8 @@ skip:
MGINFO_YELLOW(ENDL << "**********************************************************************" << ENDL MGINFO_YELLOW(ENDL << "**********************************************************************" << ENDL
<< "You are now synchronized with the network. You may now start monero-wallet-cli." << ENDL << "You are now synchronized with the network. You may now start monero-wallet-cli." << ENDL
<< ENDL << ENDL
<< "Use the \"help\" command to see the list of available commands." << ENDL << "Use the \"help\" command to see a simplified list of available commands." << ENDL
<< "Use the \"help_advanced\" command to see an advanced list of available commands." << ENDL
<< "**********************************************************************"); << "**********************************************************************");
m_sync_timer.pause(); m_sync_timer.pause();
if (ELPP->vRegistry()->allowed(el::Level::Info, "sync-info")) if (ELPP->vRegistry()->allowed(el::Level::Info, "sync-info"))

View File

@ -121,7 +121,7 @@ typedef cryptonote::simple_wallet sw;
#define SCOPED_WALLET_UNLOCK() SCOPED_WALLET_UNLOCK_ON_BAD_PASSWORD(return true;) #define SCOPED_WALLET_UNLOCK() SCOPED_WALLET_UNLOCK_ON_BAD_PASSWORD(return true;)
#define PRINT_USAGE(usage_help) fail_msg_writer() << boost::format(tr("usage: %s")) % usage_help; #define PRINT_USAGE(usage_help_advanced) fail_msg_writer() << boost::format(tr("usage: %s")) % usage_help_advanced;
#define LONG_PAYMENT_ID_SUPPORT_CHECK() \ #define LONG_PAYMENT_ID_SUPPORT_CHECK() \
do { \ do { \
@ -268,7 +268,8 @@ namespace
const char* USAGE_START_MINING_FOR_RPC("start_mining_for_rpc"); const char* USAGE_START_MINING_FOR_RPC("start_mining_for_rpc");
const char* USAGE_STOP_MINING_FOR_RPC("stop_mining_for_rpc"); const char* USAGE_STOP_MINING_FOR_RPC("stop_mining_for_rpc");
const char* USAGE_VERSION("version"); const char* USAGE_VERSION("version");
const char* USAGE_HELP("help [<command>]"); const char* USAGE_HELP_ADVANCED("help_advanced [<command>]");
const char* USAGE_HELP("help");
std::string input_line(const std::string& prompt, bool yesno = false) std::string input_line(const std::string& prompt, bool yesno = false)
{ {
@ -2315,7 +2316,7 @@ bool simple_wallet::on_unknown_command(const std::vector<std::string> &args)
{ {
if (args[0] == "exit" || args[0] == "q") // backward compat if (args[0] == "exit" || args[0] == "q") // backward compat
return false; return false;
fail_msg_writer() << boost::format(tr("Unknown command '%s', try 'help'")) % args.front(); fail_msg_writer() << boost::format(tr("Unknown command '%s', try 'help_advanced'")) % args.front();
return true; return true;
} }
@ -3043,6 +3044,30 @@ bool simple_wallet::set_export_format(const std::vector<std::string> &args/* = s
} }
bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<std::string>()*/) bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
message_writer() << "";
message_writer() << tr("Commands:");
message_writer() << "";
message_writer() << tr("\"welcome\" - Read welcome message.");
message_writer() << tr("\"donate <amount>\" - Donate XMR to the development team.");
message_writer() << tr("\"balance\" - Show balance.");
message_writer() << tr("\"address new\" - Create new subaddress.");
message_writer() << tr("\"address all\" - Show all addresses.");
message_writer() << tr("\"transfer <address> <amount>\" - Send XMR to an address.");
message_writer() << tr("\"show_transfers [in|out|pending|failed|pool]\" - Show transactions.");
message_writer() << tr("\"sweep_all <address>\" - Send whole balance to another wallet.");
message_writer() << tr("\"seed\" - Show secret 25 words that can be used to recover this wallet.");
message_writer() << tr("\"refresh\" - Synchronize wallet with the Monero network.");
message_writer() << tr("\"status\" - Check current status of wallet.");
message_writer() << tr("\"version\" - Check software version.");
message_writer() << tr("\"help_advanced\" - Show list with more available commands.");
message_writer() << tr("\"save\" - Save wallet.");
message_writer() << tr("\"exit\" - Exit wallet.");
message_writer() << "";
return true;
}
bool simple_wallet::help_advanced(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{ {
if(args.empty()) if(args.empty())
{ {
@ -3050,7 +3075,7 @@ bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<st
} }
else if ((args.size() == 2) && (args.front() == "mms")) else if ((args.size() == 2) && (args.front() == "mms"))
{ {
// Little hack to be able to do "help mms <subcommand>" // Little hack to be able to do "help_advanced mms <subcommand>"
std::vector<std::string> mms_args(1, args.front() + " " + args.back()); std::vector<std::string> mms_args(1, args.front() + " " + args.back());
success_msg_writer() << get_command_usage(mms_args); success_msg_writer() << get_command_usage(mms_args);
} }
@ -3439,7 +3464,7 @@ simple_wallet::simple_wallet()
"<subcommand> is one of:\n" "<subcommand> is one of:\n"
" init, info, signer, list, next, sync, transfer, delete, send, receive, export, note, show, set, help\n" " init, info, signer, list, next, sync, transfer, delete, send, receive, export, note, show, set, help\n"
" send_signer_config, start_auto_config, stop_auto_config, auto_config\n" " send_signer_config, start_auto_config, stop_auto_config, auto_config\n"
"Get help about a subcommand with: help mms <subcommand>, or mms help <subcommand>")); "Get help about a subcommand with: help_advanced mms <subcommand>"));
m_cmd_binder.set_handler("mms init", m_cmd_binder.set_handler("mms init",
boost::bind(&simple_wallet::on_command, this, &simple_wallet::mms, _1), boost::bind(&simple_wallet::on_command, this, &simple_wallet::mms, _1),
tr(USAGE_MMS_INIT), tr(USAGE_MMS_INIT),
@ -3589,10 +3614,14 @@ simple_wallet::simple_wallet()
boost::bind(&simple_wallet::stop_mining_for_rpc, this, _1), boost::bind(&simple_wallet::stop_mining_for_rpc, this, _1),
tr(USAGE_STOP_MINING_FOR_RPC), tr(USAGE_STOP_MINING_FOR_RPC),
tr("Stop mining to pay for RPC access")); tr("Stop mining to pay for RPC access"));
m_cmd_binder.set_handler("help_advanced",
boost::bind(&simple_wallet::on_command, this, &simple_wallet::help_advanced, _1),
tr(USAGE_HELP_ADVANCED),
tr("Show the help section or the documentation about a <command>."));
m_cmd_binder.set_handler("help", m_cmd_binder.set_handler("help",
boost::bind(&simple_wallet::on_command, this, &simple_wallet::help, _1), boost::bind(&simple_wallet::on_command, this, &simple_wallet::help, _1),
tr(USAGE_HELP), tr(USAGE_HELP),
tr("Show the help section or the documentation about a <command>.")); tr("Show simplified list of available commands."));
m_cmd_binder.set_unknown_command_handler(boost::bind(&simple_wallet::on_command, this, &simple_wallet::on_unknown_command, _1)); m_cmd_binder.set_unknown_command_handler(boost::bind(&simple_wallet::on_command, this, &simple_wallet::on_unknown_command, _1));
m_cmd_binder.set_empty_command_handler(boost::bind(&simple_wallet::on_empty_command, this)); m_cmd_binder.set_empty_command_handler(boost::bind(&simple_wallet::on_empty_command, this));
m_cmd_binder.set_cancel_handler(boost::bind(&simple_wallet::on_cancelled_command, this)); m_cmd_binder.set_cancel_handler(boost::bind(&simple_wallet::on_cancelled_command, this));
@ -4744,8 +4773,9 @@ boost::optional<epee::wipeable_string> simple_wallet::new_wallet(const boost::pr
"**********************************************************************\n" << "**********************************************************************\n" <<
tr("Your wallet has been generated!\n" tr("Your wallet has been generated!\n"
"To start synchronizing with the daemon, use the \"refresh\" command.\n" "To start synchronizing with the daemon, use the \"refresh\" command.\n"
"Use the \"help\" command to see the list of available commands.\n" "Use the \"help\" command to see a simplified list of available commands.\n"
"Use \"help <command>\" to see a command's documentation.\n" "Use the \"help_advanced\" command to see an advanced list of available commands.\n"
"Use \"help_advanced <command>\" to see a command's documentation.\n"
"Always use the \"exit\" command when closing monero-wallet-cli to save \n" "Always use the \"exit\" command when closing monero-wallet-cli to save \n"
"your current session's state. Otherwise, you might need to synchronize \n" "your current session's state. Otherwise, you might need to synchronize \n"
"your wallet again (your wallet keys are NOT at risk in any case).\n") "your wallet again (your wallet keys are NOT at risk in any case).\n")
@ -5004,8 +5034,9 @@ boost::optional<epee::wipeable_string> simple_wallet::open_wallet(const boost::p
} }
success_msg_writer() << success_msg_writer() <<
"**********************************************************************\n" << "**********************************************************************\n" <<
tr("Use the \"help\" command to see the list of available commands.\n") << tr("Use the \"help\" command to see a simplified list of available commands.\n") <<
tr("Use \"help <command>\" to see a command's documentation.\n") << tr("Use the \"help_advanced\" command to see an advanced list of available commands.\n") <<
tr("Use \"help_advanced <command>\" to see a command's documentation.\n") <<
"**********************************************************************"; "**********************************************************************";
return password; return password;
} }
@ -11016,7 +11047,7 @@ void simple_wallet::mms_help(const std::vector<std::string> &args)
{ {
if (args.size() > 1) if (args.size() > 1)
{ {
fail_msg_writer() << tr("Usage: mms help [<subcommand>]"); fail_msg_writer() << tr("Usage: help_advanced mms [<subcommand>]");
return; return;
} }
std::vector<std::string> help_args; std::vector<std::string> help_args;

View File

@ -154,6 +154,7 @@ namespace cryptonote
bool set_persistent_rpc_client_id(const std::vector<std::string> &args = std::vector<std::string>()); bool set_persistent_rpc_client_id(const std::vector<std::string> &args = std::vector<std::string>());
bool set_auto_mine_for_rpc_payment_threshold(const std::vector<std::string> &args = std::vector<std::string>()); bool set_auto_mine_for_rpc_payment_threshold(const std::vector<std::string> &args = std::vector<std::string>());
bool set_credits_target(const std::vector<std::string> &args = std::vector<std::string>()); bool set_credits_target(const std::vector<std::string> &args = std::vector<std::string>());
bool help_advanced(const std::vector<std::string> &args = std::vector<std::string>());
bool help(const std::vector<std::string> &args = std::vector<std::string>()); bool help(const std::vector<std::string> &args = std::vector<std::string>());
bool start_mining(const std::vector<std::string> &args); bool start_mining(const std::vector<std::string> &args);
bool stop_mining(const std::vector<std::string> &args); bool stop_mining(const std::vector<std::string> &args);