aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/command_line.cpp12
-rw-r--r--src/common/command_line.h3
-rw-r--r--src/simplewallet/simplewallet.cpp10
3 files changed, 19 insertions, 6 deletions
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp
index 0b90345d9..d507f36a7 100644
--- a/src/common/command_line.cpp
+++ b/src/common/command_line.cpp
@@ -3,9 +3,21 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "command_line.h"
+#include "string_tools.h"
namespace command_line
{
+ std::string input_line(const std::string& prompt)
+ {
+ std::cout << prompt;
+
+ std::string buf;
+ std::getline(std::cin, buf);
+
+ return epee::string_tools::trim(buf);
+
+ }
+
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 860653772..a6f78569c 100644
--- a/src/common/command_line.h
+++ b/src/common/command_line.h
@@ -14,6 +14,9 @@
namespace command_line
{
+
+ std::string input_line(const std::string& prompt);
+
template<typename T, bool required = false>
struct arg_descriptor;
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 55099199d..24ecb4504 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -212,12 +212,10 @@ bool simple_wallet::ask_wallet_create_if_needed()
{
std::string wallet_path;
- std::cout << "Specify wallet file name (e.g., wallet.bin). If the wallet doesn't exist, it will be created.\n";
- std::cout << "Wallet file name: ";
-
- std::getline(std::cin, wallet_path);
-
- wallet_path = string_tools::trim(wallet_path);
+ wallet_path = command_line::input_line(
+ "Specify wallet file name (e.g., wallet.bin). If the wallet doesn't exist, it will be created.\n"
+ "Wallet file name: "
+ );
bool keys_file_exists;
bool wallet_file_exists;