96 {
97 namespace bf = boost::filesystem;
98 namespace po = boost::program_options;
99#ifdef WIN32
100 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
101#endif
102
105 const command_line::arg_descriptor<std::size_t>
arg_max_log_files = {
"max-log-files",
"Specify maximum number of rotated log files to be saved (no limit by setting to 0)",
MAX_LOG_FILES};
109
110
113#ifdef NDEBUG
115#endif
117
119
120 po::options_description desc_general(
wallet_args::tr(
"General options"));
123
130
132
133 po::options_description desc_all;
134 desc_all.add(desc_general).add(desc_params);
135 po::variables_map vm;
136 bool should_terminate = false;
138 {
139 auto parser = po::command_line_parser(argc, argv).options(desc_all).positional(positional_options);
140 po::store(parser.run(), vm);
141
143 {
145 Print(print) <<
wallet_args::tr(
"This is the command line electroneum wallet. It needs to connect to a electroneum\n"
146 "daemon to work correctly.") <<
ENDL;
148 Print(print) << desc_all;
149 should_terminate = true;
150 return true;
151 }
153 {
155 should_terminate = true;
156 return true;
157 }
158
160 {
162 bf::path config_path(config);
163 boost::system::error_code ec;
164 if (bf::exists(config_path, ec))
165 {
166 po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_params), vm);
167 }
168 else
169 {
171 return false;
172 }
173 }
174
175 po::notify(vm);
176 return true;
177 });
178 if (!r)
179 return {boost::none, true};
180
181 if (should_terminate)
182 return {std::move(vm), should_terminate};
183
184 std::string log_path;
187 else
191 {
193 }
194 else if (!log_to_console)
195 {
197 }
198
200 {
202 Print(print) <<
wallet_args::tr(
"This is the command line electroneum wallet. It needs to connect to a electroneum\n"
203 "daemon to work correctly.") <<
ENDL;
205 Print(print) << desc_all;
206 return {boost::none, true};
207 }
209 {
211 return {boost::none, true};
212 }
213
214 if (notice)
215 Print(print) << notice <<
ENDL;
216
219
221
224 else
225 MINFO(
"Setting log levels = " << getenv(
"ELECTRONEUM_LOGS"));
227
228 Print(print) << boost::format(
wallet_args::tr(
"Logging to %s")) % log_path;
229
231 if (lockable_memory >= 0 && lockable_memory < 256 * 4096)
232 Print(print) <<
tr(
"WARNING: You may not have a high enough lockable memory limit")
233#ifdef ELPP_OS_UNIX
234 <<
", " <<
tr(
"see ulimit -l")
235#endif
236 ;
237
238 return {std::move(vm), should_terminate};
239 }
std::string i18n_get_language()
int i18n_set_language(const char *directory, const char *base, std::string language)
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size=MAX_LOG_FILE_SIZE, const std::size_t max_log_files=MAX_LOG_FILES)
std::string mlog_get_default_log_path(const char *default_filename)
void mlog_set_log(const char *log)
void mlog_set_categories(const char *categories)
#define MAX_LOG_FILE_SIZE
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
const arg_descriptor< bool > arg_help
const arg_descriptor< bool > arg_version
bool is_arg_defaulted(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
std::enable_if<!std::is_same< T, bool >::value, bool >::type has_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
const command_line::arg_descriptor< std::string, false, true, 2 > arg_log_file
const command_line::arg_descriptor< std::size_t > arg_max_log_files
const command_line::arg_descriptor< std::string, false, true, 2 > arg_config_file
const command_line::arg_descriptor< unsigned > arg_max_concurrency
const char *const ELECTRONEUM_RELEASE_NAME
const char *const ELECTRONEUM_VERSION_FULL
#define DEFAULT_MAX_CONCURRENCY