diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-02-17 11:51:57 +0100 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-02-17 11:51:57 +0100 |
commit | 6198c816b1749dbe55a74084ea65694d8a391046 (patch) | |
tree | 2fb5dc0857792bea59242950c70f76a006fefee5 /src/cryptonote_core | |
parent | Merge pull request #3191 (diff) | |
parent | options: add testnet option dependencies (diff) | |
download | monero-6198c816b1749dbe55a74084ea65694d8a391046.tar.xz |
Merge pull request #3170
b3b2d4d2 options: add testnet option dependencies (whythat)
c5f55bb4 common: implement dynamic option dependencies mechanism (whythat)
05a12ccc options: remove testnet-* options (whythat)
c33cb60e common: implement dependent option descriptor (whythat)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 25 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 3 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 786d21aa1..e0430a18a 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -66,19 +66,22 @@ DISABLE_VS_WARNINGS(4355) namespace cryptonote { - const command_line::arg_descriptor<std::string> arg_data_dir = { - "data-dir" - , "Specify data directory" - }; - const command_line::arg_descriptor<std::string> arg_testnet_data_dir = { - "testnet-data-dir" - , "Specify testnet data directory" - }; const command_line::arg_descriptor<bool, false> arg_testnet_on = { "testnet" , "Run on testnet. The wallet must be launched with --testnet flag." , false }; + const command_line::arg_descriptor<std::string, false, true> arg_data_dir = { + "data-dir" + , "Specify data directory" + , tools::get_default_data_dir() + , arg_testnet_on + , [](bool testnet, bool defaulted, std::string val) { + if (testnet) + return (boost::filesystem::path(val) / "testnet").string(); + return val; + } + }; const command_line::arg_descriptor<bool> arg_offline = { "offline" , "Do not listen for peers, nor connect to any" @@ -234,8 +237,7 @@ namespace cryptonote //----------------------------------------------------------------------------------- void core::init_options(boost::program_options::options_description& desc) { - command_line::add_arg(desc, arg_data_dir, tools::get_default_data_dir()); - command_line::add_arg(desc, arg_testnet_data_dir, (boost::filesystem::path(tools::get_default_data_dir()) / "testnet").string()); + command_line::add_arg(desc, arg_data_dir); command_line::add_arg(desc, arg_test_drop_download); command_line::add_arg(desc, arg_test_drop_download_height); @@ -262,8 +264,7 @@ namespace cryptonote { m_testnet = command_line::get_arg(vm, arg_testnet_on); - auto data_dir_arg = m_testnet ? arg_testnet_data_dir : arg_data_dir; - m_config_folder = command_line::get_arg(vm, data_dir_arg); + m_config_folder = command_line::get_arg(vm, arg_data_dir); auto data_dir = boost::filesystem::path(m_config_folder); diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 429f6b820..ce39aaddf 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -58,8 +58,7 @@ namespace cryptonote const std::pair<uint8_t, uint64_t> *hard_forks; }; - extern const command_line::arg_descriptor<std::string> arg_data_dir; - extern const command_line::arg_descriptor<std::string> arg_testnet_data_dir; + extern const command_line::arg_descriptor<std::string, false, true> arg_data_dir; extern const command_line::arg_descriptor<bool, false> arg_testnet_on; extern const command_line::arg_descriptor<bool> arg_offline; |