refactor
This commit is contained in:
parent
28065c2c8e
commit
96c712ae9c
@ -72,59 +72,60 @@ auto main(int argc, char **argv) -> int {
|
|||||||
std::string remote_host;
|
std::string remote_host;
|
||||||
std::uint16_t remote_port{};
|
std::uint16_t remote_port{};
|
||||||
std::string unique_id;
|
std::string unique_id;
|
||||||
if ((res == exit_code::success) && (prov == provider_type::remote)) {
|
if (res == exit_code::success) {
|
||||||
std::string data;
|
if (prov == provider_type::remote) {
|
||||||
res = utils::cli::parse_string_option(
|
std::string data;
|
||||||
args, utils::cli::options::remote_mount_option, data);
|
res = utils::cli::parse_string_option(
|
||||||
if (res == exit_code::success) {
|
args, utils::cli::options::remote_mount_option, data);
|
||||||
const auto parts = utils::string::split(data, ':', false);
|
if (res == exit_code::success) {
|
||||||
if (parts.size() != 2) {
|
const auto parts = utils::string::split(data, ':', false);
|
||||||
std::cerr << "Invalid syntax for host/port '-rm "
|
if (parts.size() != 2) {
|
||||||
"host:port,--remote_mount host:port'"
|
std::cerr << "Invalid syntax for host/port '-rm "
|
||||||
<< std::endl;
|
"host:port,--remote_mount host:port'"
|
||||||
res = exit_code::invalid_syntax;
|
|
||||||
} else {
|
|
||||||
unique_id = parts.at(0U) + ':' + parts.at(1U);
|
|
||||||
remote_host = parts.at(0U);
|
|
||||||
try {
|
|
||||||
remote_port = utils::string::to_uint16(parts.at(1U));
|
|
||||||
data_directory = utils::path::combine(
|
|
||||||
data_directory.empty() ? app_config::default_data_directory(prov)
|
|
||||||
: data_directory,
|
|
||||||
{utils::string::replace_copy(unique_id, ':', '_')});
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
std::cerr << (e.what() == nullptr ? "Unable to parse port" : e.what())
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
res = exit_code::invalid_syntax;
|
res = exit_code::invalid_syntax;
|
||||||
|
} else {
|
||||||
|
unique_id = parts.at(0U) + ':' + parts.at(1U);
|
||||||
|
remote_host = parts.at(0U);
|
||||||
|
try {
|
||||||
|
remote_port = utils::string::to_uint16(parts.at(1U));
|
||||||
|
data_directory = utils::path::combine(
|
||||||
|
data_directory.empty()
|
||||||
|
? app_config::default_data_directory(prov)
|
||||||
|
: data_directory,
|
||||||
|
{utils::string::replace_copy(unique_id, ':', '_')});
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
std::cerr << (e.what() == nullptr ? "Unable to parse port"
|
||||||
|
: e.what())
|
||||||
|
<< std::endl;
|
||||||
|
res = exit_code::invalid_syntax;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (((prov == provider_type::s3) || (prov == provider_type::sia))) {
|
||||||
}
|
std::string data;
|
||||||
|
res = utils::cli::parse_string_option(
|
||||||
if ((res == exit_code::success) &&
|
args, utils::cli::options::name_option, data);
|
||||||
((prov == provider_type::s3) || (prov == provider_type::sia))) {
|
if (res == exit_code::success) {
|
||||||
std::string data;
|
unique_id = utils::string::trim(data);
|
||||||
res = utils::cli::parse_string_option(
|
if (unique_id.empty()) {
|
||||||
args, utils::cli::options::name_option, data);
|
std::cerr << "Name of " << app_config::get_provider_name(prov)
|
||||||
if (res == exit_code::success) {
|
<< " instance not provided" << std::endl;
|
||||||
unique_id = utils::string::trim(data);
|
res = exit_code::invalid_syntax;
|
||||||
if (unique_id.empty()) {
|
}
|
||||||
std::cerr << "Name of " << app_config::get_provider_name(prov)
|
} else if (res == exit_code::option_not_found &&
|
||||||
<< " instance not provided" << std::endl;
|
prov == provider_type::sia) {
|
||||||
res = exit_code::invalid_syntax;
|
unique_id = "default";
|
||||||
|
res = exit_code::success;
|
||||||
}
|
}
|
||||||
} else if (res == exit_code::option_not_found &&
|
|
||||||
prov == provider_type::sia) {
|
|
||||||
unique_id = "default";
|
|
||||||
res = exit_code::success;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res == exit_code::success) {
|
if (res == exit_code::success) {
|
||||||
data_directory =
|
data_directory =
|
||||||
data_directory.empty()
|
data_directory.empty()
|
||||||
? utils::path::combine(app_config::default_data_directory(prov),
|
? utils::path::combine(app_config::default_data_directory(prov),
|
||||||
{unique_id})
|
{unique_id})
|
||||||
: utils::path::absolute(data_directory);
|
: utils::path::absolute(data_directory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user