forked from lthn/blockchain
implemented #242
This commit is contained in:
parent
3babaa4f07
commit
7873ef2acc
6 changed files with 36 additions and 10 deletions
|
|
@ -152,6 +152,13 @@ namespace command_line
|
|||
|
||||
template<typename F>
|
||||
bool handle_error_helper(const boost::program_options::options_description& desc, F parser)
|
||||
{
|
||||
std::string stub_err;
|
||||
return handle_error_helper(desc, stub_err, parser);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
bool handle_error_helper(const boost::program_options::options_description& desc, std::string& err, F parser)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -159,6 +166,7 @@ namespace command_line
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
err = e.what();
|
||||
std::cerr << "Failed to parse arguments: " << e.what() << std::endl;
|
||||
std::cerr << desc << std::endl;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -729,14 +729,26 @@ void qt_log_message_handler(QtMsgType type, const QMessageLogContext &context, c
|
|||
bool MainWindow::init_backend(int argc, char* argv[])
|
||||
{
|
||||
TRY_ENTRY();
|
||||
if (!m_backend.init_command_line(argc, argv))
|
||||
std::string command_line_fail_details;
|
||||
if (!m_backend.init_command_line(argc, argv, command_line_fail_details))
|
||||
{
|
||||
this->show_msg_box(command_line_fail_details);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!init_window())
|
||||
{
|
||||
this->show_msg_box("Failed to main screen launch, check logs for the more detais.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_backend.init(this))
|
||||
{
|
||||
this->show_msg_box("Failed to initialize backend, check debug logs for more details.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (m_backend.is_qt_logs_enabled())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ int main(int argc, char *argv[])
|
|||
MainWindow viewer;
|
||||
if (!viewer.init_backend(argc, argv))
|
||||
{
|
||||
static_cast<view::i_view*>(&viewer)->show_msg_box("Failed to initialize backend, check debug logs for more details.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
app.installNativeEventFilter(&viewer);
|
||||
viewer.setWindowTitle(CURRENCY_NAME_BASE);
|
||||
viewer.show_inital();
|
||||
|
|
|
|||
|
|
@ -201,7 +201,8 @@ namespace plain_wallet
|
|||
args[1] = const_cast<char*>(argss_1.c_str());
|
||||
args[2] = const_cast<char*>(argss_2.c_str());
|
||||
args[3] = nullptr;
|
||||
if (!(ptr->gwm.init_command_line(3, args) && ptr->gwm.init(nullptr)))
|
||||
std::string command_line_fail_details;
|
||||
if (!(ptr->gwm.init_command_line(3, args, command_line_fail_details) && ptr->gwm.init(nullptr)))
|
||||
{
|
||||
LOG_ERROR("Failed to init wallets_manager");
|
||||
return GENERAL_INTERNAL_ERRROR_INIT;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ bool wallets_manager::do_exception_safe_call(guarded_code_t guarded_code, error_
|
|||
}
|
||||
|
||||
|
||||
bool wallets_manager::init_command_line(int argc, char* argv[])
|
||||
bool wallets_manager::init_command_line(int argc, char* argv[], std::string& fail_message)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
po::options_description desc_cmd_only("Command line options");
|
||||
|
|
@ -197,9 +197,8 @@ bool wallets_manager::init_command_line(int argc, char* argv[])
|
|||
po::options_description desc_options("Allowed options");
|
||||
desc_options.add(desc_cmd_only).add(desc_cmd_sett);
|
||||
|
||||
|
||||
|
||||
bool coomand_line_parsed = command_line::handle_error_helper(desc_options, [&]()
|
||||
std::string err_str;
|
||||
bool command_line_parsed = command_line::handle_error_helper(desc_options, err_str, [&]()
|
||||
{
|
||||
po::store(po::parse_command_line(argc, argv, desc_options), m_vm);
|
||||
|
||||
|
|
@ -230,23 +229,29 @@ bool wallets_manager::init_command_line(int argc, char* argv[])
|
|||
return true;
|
||||
});
|
||||
|
||||
if (!coomand_line_parsed)
|
||||
if (!command_line_parsed)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Command line has wrong arguments: " << std::endl;
|
||||
for (int i = 0; i != argc; i++)
|
||||
ss << "[" << i << "] " << argv[i] << std::endl;
|
||||
std::cerr << ss.str() << std::endl << std::flush;
|
||||
|
||||
fail_message = "Error parsing arguments.\n";
|
||||
fail_message += err_str + "\n";
|
||||
std::stringstream s;
|
||||
desc_options.print(s);
|
||||
fail_message += s.str();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_qt_logs_enbaled = command_line::get_arg(m_vm, arg_enable_qt_logs);
|
||||
m_qt_dev_tools = command_line::get_arg(m_vm, arg_qt_dev_tools);
|
||||
|
||||
return true;
|
||||
CATCH_ENTRY2(false);
|
||||
}
|
||||
|
||||
|
||||
void terminate_handler_func()
|
||||
{
|
||||
LOG_ERROR("\n\nTERMINATE HANDLER\n"); // should print callstack
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public:
|
|||
|
||||
wallets_manager();
|
||||
~wallets_manager();
|
||||
bool init_command_line(int argc, char* argv[]);
|
||||
bool init_command_line(int argc, char* argv[], std::string& fail_message);
|
||||
bool init(view::i_view* pview_handler);
|
||||
bool start();
|
||||
bool stop();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue