|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <filesystem> |
|
|
#include <filesystem> |
|
|
#include <iostream> |
|
|
#include <iostream> |
|
|
|
|
|
#include <locale> |
|
|
|
|
|
|
|
|
|
|
|
static void load_locale() { |
|
|
|
|
|
auto lang = std::getenv("LANG"); |
|
|
|
|
|
if (!lang) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
std::locale::global(std::locale(lang)); |
|
|
|
|
|
} catch (const std::runtime_error& e) { |
|
|
|
|
|
// No locale with the given name |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int main_fn(std::string_view program_name, const std::vector<std::string>& argv) { |
|
|
int main_fn(std::string_view program_name, const std::vector<std::string>& argv) { |
|
|
dds::log::init_logger(); |
|
|
dds::log::init_logger(); |
|
|
auto log_subscr = neo::subscribe(&dds::log::ev_log::print); |
|
|
auto log_subscr = neo::subscribe(&dds::log::ev_log::print); |
|
|
|
|
|
load_locale(); |
|
|
|
|
|
std::setlocale(LC_CTYPE, ".utf8"); |
|
|
|
|
|
|
|
|
dds::install_signal_handlers(); |
|
|
dds::install_signal_handlers(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Non-null result from argument parsing, return that value immediately. |
|
|
// Non-null result from argument parsing, return that value immediately. |
|
|
return *result; |
|
|
return *result; |
|
|
} |
|
|
} |
|
|
|
|
|
dds::log::current_log_level = opts.log_level; |
|
|
return dds::cli::dispatch_main(opts); |
|
|
return dds::cli::dispatch_main(opts); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int wmain(int argc, wchar_t** argv) { |
|
|
int wmain(int argc, wchar_t** argv) { |
|
|
std::vector<std::string> u8_argv; |
|
|
std::vector<std::string> u8_argv; |
|
|
::setlocale(LC_ALL, ".utf8"); |
|
|
|
|
|
for (int i = 0; i < argc; ++i) { |
|
|
for (int i = 0; i < argc; ++i) { |
|
|
u8_argv.emplace_back(wstr_to_u8str(argv[i])); |
|
|
u8_argv.emplace_back(wstr_to_u8str(argv[i])); |
|
|
} |
|
|
} |