updates
This commit is contained in:
@@ -1,93 +1,93 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_ACTIONS_HPP_
|
||||
#define INCLUDE_CLI_ACTIONS_HPP_
|
||||
|
||||
#include "cli/check_version.hpp"
|
||||
#include "cli/display_config.hpp"
|
||||
#include "cli/drive_information.hpp"
|
||||
#include "cli/get.hpp"
|
||||
#include "cli/get_directory_items.hpp"
|
||||
#include "cli/get_pinned_files.hpp"
|
||||
#include "cli/help.hpp"
|
||||
#include "cli/mount.hpp"
|
||||
#include "cli/open_files.hpp"
|
||||
#include "cli/pin_file.hpp"
|
||||
#include "cli/pinned_status.hpp"
|
||||
#include "cli/set.hpp"
|
||||
#include "cli/status.hpp"
|
||||
#include "cli/unmount.hpp"
|
||||
#include "cli/unpin_file.hpp"
|
||||
#include "cli/version.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
using action = std::function<exit_code(
|
||||
std::vector<const char *>, const std::string &, const provider_type &,
|
||||
const std::string &, std::string, std::string)>;
|
||||
|
||||
struct option_hasher {
|
||||
auto operator()(const utils::cli::option &opt) const -> std::size_t {
|
||||
return std::hash<std::string>()(opt[0U] + '|' + opt[1U]);
|
||||
}
|
||||
};
|
||||
|
||||
static const std::unordered_map<utils::cli::option, action, option_hasher>
|
||||
option_actions = {
|
||||
{utils::cli::options::check_version_option,
|
||||
cli::actions::check_version},
|
||||
{utils::cli::options::display_config_option,
|
||||
cli::actions::display_config},
|
||||
{utils::cli::options::drive_information_option,
|
||||
cli::actions::drive_information},
|
||||
{utils::cli::options::get_directory_items_option,
|
||||
cli::actions::get_directory_items},
|
||||
{utils::cli::options::get_option, cli::actions::get},
|
||||
{utils::cli::options::get_pinned_files_option,
|
||||
cli::actions::get_pinned_files},
|
||||
{utils::cli::options::open_files_option, cli::actions::open_files},
|
||||
{utils::cli::options::pin_file_option, cli::actions::pin_file},
|
||||
{utils::cli::options::pinned_status_option,
|
||||
cli::actions::pinned_status},
|
||||
{utils::cli::options::set_option, cli::actions::set},
|
||||
{utils::cli::options::status_option, cli::actions::status},
|
||||
{utils::cli::options::unmount_option, cli::actions::unmount},
|
||||
{utils::cli::options::unpin_file_option, cli::actions::unpin_file},
|
||||
};
|
||||
|
||||
[[nodiscard]] inline auto
|
||||
perform_action(const utils::cli::option &opt, std::vector<const char *> args,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
if (utils::cli::has_option(args, opt)) {
|
||||
if (option_actions.find(opt) != option_actions.end()) {
|
||||
return option_actions.at(opt)(args, data_directory, prov, unique_id, user,
|
||||
password);
|
||||
}
|
||||
}
|
||||
|
||||
return exit_code::option_not_found;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_ACTIONS_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_ACTIONS_HPP_
|
||||
#define INCLUDE_CLI_ACTIONS_HPP_
|
||||
|
||||
#include "cli/check_version.hpp"
|
||||
#include "cli/display_config.hpp"
|
||||
#include "cli/drive_information.hpp"
|
||||
#include "cli/get.hpp"
|
||||
#include "cli/get_directory_items.hpp"
|
||||
#include "cli/get_pinned_files.hpp"
|
||||
#include "cli/help.hpp"
|
||||
#include "cli/mount.hpp"
|
||||
#include "cli/open_files.hpp"
|
||||
#include "cli/pin_file.hpp"
|
||||
#include "cli/pinned_status.hpp"
|
||||
#include "cli/set.hpp"
|
||||
#include "cli/status.hpp"
|
||||
#include "cli/unmount.hpp"
|
||||
#include "cli/unpin_file.hpp"
|
||||
#include "cli/version.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
using action = std::function<exit_code(
|
||||
std::vector<const char *>, const std::string &, const provider_type &,
|
||||
const std::string &, std::string, std::string)>;
|
||||
|
||||
struct option_hasher {
|
||||
auto operator()(const utils::cli::option &opt) const -> std::size_t {
|
||||
return std::hash<std::string>()(opt[0U] + '|' + opt[1U]);
|
||||
}
|
||||
};
|
||||
|
||||
static const std::unordered_map<utils::cli::option, action, option_hasher>
|
||||
option_actions = {
|
||||
{utils::cli::options::check_version_option,
|
||||
cli::actions::check_version},
|
||||
{utils::cli::options::display_config_option,
|
||||
cli::actions::display_config},
|
||||
{utils::cli::options::drive_information_option,
|
||||
cli::actions::drive_information},
|
||||
{utils::cli::options::get_directory_items_option,
|
||||
cli::actions::get_directory_items},
|
||||
{utils::cli::options::get_option, cli::actions::get},
|
||||
{utils::cli::options::get_pinned_files_option,
|
||||
cli::actions::get_pinned_files},
|
||||
{utils::cli::options::open_files_option, cli::actions::open_files},
|
||||
{utils::cli::options::pin_file_option, cli::actions::pin_file},
|
||||
{utils::cli::options::pinned_status_option,
|
||||
cli::actions::pinned_status},
|
||||
{utils::cli::options::set_option, cli::actions::set},
|
||||
{utils::cli::options::status_option, cli::actions::status},
|
||||
{utils::cli::options::unmount_option, cli::actions::unmount},
|
||||
{utils::cli::options::unpin_file_option, cli::actions::unpin_file},
|
||||
};
|
||||
|
||||
[[nodiscard]] inline auto
|
||||
perform_action(const utils::cli::option &opt, std::vector<const char *> args,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
if (utils::cli::has_option(args, opt)) {
|
||||
if (option_actions.find(opt) != option_actions.end()) {
|
||||
return option_actions.at(opt)(args, data_directory, prov, unique_id, user,
|
||||
password);
|
||||
}
|
||||
}
|
||||
|
||||
return exit_code::option_not_found;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_ACTIONS_HPP_
|
||||
|
@@ -1,73 +1,73 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_CHECK_VERSION_HPP_
|
||||
#define INCLUDE_CLI_CHECK_VERSION_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
check_version(std::vector<const char *> /* args */,
|
||||
const std::string & /* data_directory */,
|
||||
const provider_type & /* pt */, const std::string & /*unique_id*/,
|
||||
std::string /*user*/, std::string /*password*/) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
// TODO need to updated way to check version
|
||||
// if (not((pt == provider_type::remote) || (pt == provider_type::s3))) {
|
||||
// app_config config(pt, data_directory);
|
||||
// curl_comm comm(config);
|
||||
// json data, err;
|
||||
//
|
||||
// if (comm.get("/daemon/version", data, err) == api_error::success) {
|
||||
// const auto res = utils::compare_version_strings(
|
||||
// data["version"].get<std::string>(),
|
||||
// app_config::get_provider_minimum_version(pt));
|
||||
// if (res < 0) {
|
||||
// ret = exit_code::incompatible_version;
|
||||
// std::cerr << "Failed!" << std::endl;
|
||||
// std::cerr << " Actual: " << data["version"].get<std::string>()
|
||||
// << std::endl;
|
||||
// std::cerr << " Minimum: "
|
||||
// << app_config::get_provider_minimum_version(pt) <<
|
||||
// std::endl;
|
||||
// } else {
|
||||
// std::cout << "Success!" << std::endl;
|
||||
// std::cout << " Actual: " << data["version"].get<std::string>()
|
||||
// << std::endl;
|
||||
// std::cout << " Minimum: "
|
||||
// << app_config::get_provider_minimum_version(pt) <<
|
||||
// std::endl;
|
||||
// }
|
||||
// } else {
|
||||
// std::cerr << "Failed!" << std::endl;
|
||||
// std::cerr << err.dump(2) << std::endl;
|
||||
// ret = exit_code::communication_error;
|
||||
// }
|
||||
// }
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_CHECK_VERSION_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_CHECK_VERSION_HPP_
|
||||
#define INCLUDE_CLI_CHECK_VERSION_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
check_version(std::vector<const char *> /* args */,
|
||||
const std::string & /* data_directory */,
|
||||
const provider_type & /* pt */, const std::string & /*unique_id*/,
|
||||
std::string /*user*/, std::string /*password*/) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
// TODO need to updated way to check version
|
||||
// if (not((pt == provider_type::remote) || (pt == provider_type::s3))) {
|
||||
// app_config config(pt, data_directory);
|
||||
// curl_comm comm(config);
|
||||
// json data, err;
|
||||
//
|
||||
// if (comm.get("/daemon/version", data, err) == api_error::success) {
|
||||
// const auto res = utils::compare_version_strings(
|
||||
// data["version"].get<std::string>(),
|
||||
// app_config::get_provider_minimum_version(pt));
|
||||
// if (res < 0) {
|
||||
// ret = exit_code::incompatible_version;
|
||||
// std::cerr << "Failed!" << std::endl;
|
||||
// std::cerr << " Actual: " << data["version"].get<std::string>()
|
||||
// << std::endl;
|
||||
// std::cerr << " Minimum: "
|
||||
// << app_config::get_provider_minimum_version(pt) <<
|
||||
// std::endl;
|
||||
// } else {
|
||||
// std::cout << "Success!" << std::endl;
|
||||
// std::cout << " Actual: " << data["version"].get<std::string>()
|
||||
// << std::endl;
|
||||
// std::cout << " Minimum: "
|
||||
// << app_config::get_provider_minimum_version(pt) <<
|
||||
// std::endl;
|
||||
// }
|
||||
// } else {
|
||||
// std::cerr << "Failed!" << std::endl;
|
||||
// std::cerr << err.dump(2) << std::endl;
|
||||
// ret = exit_code::communication_error;
|
||||
// }
|
||||
// }
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_CHECK_VERSION_HPP_
|
||||
|
@@ -1,60 +1,60 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_DISPLAY_CONFIG_HPP_
|
||||
#define INCLUDE_CLI_DISPLAY_CONFIG_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto display_config(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id,
|
||||
std::string user, std::string password)
|
||||
-> exit_code {
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(prov, data_directory);
|
||||
const auto cfg = config.get_json();
|
||||
std::cout << 0 << std::endl;
|
||||
std::cout << cfg.dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_config();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
}
|
||||
|
||||
return exit_code::success;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_DISPLAY_CONFIG_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_DISPLAY_CONFIG_HPP_
|
||||
#define INCLUDE_CLI_DISPLAY_CONFIG_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto display_config(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id,
|
||||
std::string user, std::string password)
|
||||
-> exit_code {
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(prov, data_directory);
|
||||
const auto cfg = config.get_json();
|
||||
std::cout << 0 << std::endl;
|
||||
std::cout << cfg.dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_config();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
}
|
||||
|
||||
return exit_code::success;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_DISPLAY_CONFIG_HPP_
|
||||
|
@@ -1,60 +1,60 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_DRIVE_INFORMATION_HPP_
|
||||
#define INCLUDE_CLI_DRIVE_INFORMATION_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
drive_information(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_drive_information();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " is not mounted." << std::endl;
|
||||
ret = exit_code::not_mounted;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_DRIVE_INFORMATION_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_DRIVE_INFORMATION_HPP_
|
||||
#define INCLUDE_CLI_DRIVE_INFORMATION_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
drive_information(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_drive_information();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " is not mounted." << std::endl;
|
||||
ret = exit_code::not_mounted;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_DRIVE_INFORMATION_HPP_
|
||||
|
@@ -1,68 +1,68 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_GET_HPP_
|
||||
#define INCLUDE_CLI_GET_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto get(std::vector<const char *> args,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::get_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(prov, data_directory);
|
||||
const auto value = config.get_value_by_name(data);
|
||||
std::cout << (value.empty()
|
||||
? static_cast<int>(
|
||||
rpc_response_type::config_value_not_found)
|
||||
: 0)
|
||||
<< std::endl;
|
||||
std::cout << json({{"value", value}}).dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user})
|
||||
.get_config_value_by_name(data);
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_GET_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_GET_HPP_
|
||||
#define INCLUDE_CLI_GET_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto get(std::vector<const char *> args,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::get_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(prov, data_directory);
|
||||
const auto value = config.get_value_by_name(data);
|
||||
std::cout << (value.empty()
|
||||
? static_cast<int>(
|
||||
rpc_response_type::config_value_not_found)
|
||||
: 0)
|
||||
<< std::endl;
|
||||
std::cout << json({{"value", value}}).dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user})
|
||||
.get_config_value_by_name(data);
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_GET_HPP_
|
||||
|
@@ -1,57 +1,57 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_GET_DIRECTORY_ITEMS_HPP_
|
||||
#define INCLUDE_CLI_GET_DIRECTORY_ITEMS_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto get_directory_items(
|
||||
std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /* unique_id */,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::get_directory_items_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_directory_items(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::export_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_GETDIRECTORYITEMS_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_GET_DIRECTORY_ITEMS_HPP_
|
||||
#define INCLUDE_CLI_GET_DIRECTORY_ITEMS_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto get_directory_items(
|
||||
std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /* unique_id */,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::get_directory_items_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_directory_items(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::export_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_GETDIRECTORYITEMS_HPP_
|
||||
|
@@ -1,55 +1,55 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_GET_PINNED_FILES_HPP_
|
||||
#define INCLUDE_CLI_GET_PINNED_FILES_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto get_pinned_files(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string & /* unique_id */,
|
||||
std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_pinned_files();
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::export_failed;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_GET_PINNED_FILES_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_GET_PINNED_FILES_HPP_
|
||||
#define INCLUDE_CLI_GET_PINNED_FILES_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto get_pinned_files(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string & /* unique_id */,
|
||||
std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_pinned_files();
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::export_failed;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_GET_PINNED_FILES_HPP_
|
||||
|
@@ -1,95 +1,95 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_HELP_HPP_
|
||||
#define INCLUDE_CLI_HELP_HPP_
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
template <typename drive> inline void help(std::vector<const char *> args) {
|
||||
drive::display_options(args);
|
||||
std::cout << "Repertory options:" << std::endl;
|
||||
std::cout << " -cv,--check_version Check daemon version "
|
||||
"compatibility"
|
||||
<< std::endl;
|
||||
std::cout << " -dc,--display_config Display configuration"
|
||||
<< std::endl;
|
||||
std::cout << " -dd,--data_directory [directory] Override data directory"
|
||||
<< std::endl;
|
||||
std::cout << " -di,--drive_information Display mounted drive "
|
||||
"information"
|
||||
<< std::endl;
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
std::cout << " -s3,--s3 Enables S3 mode"
|
||||
<< std::endl;
|
||||
std::cout << " -na,--name Unique name for S3 "
|
||||
"instance [Required]"
|
||||
<< std::endl;
|
||||
#endif // defined(REPERTORY_ENABLE_S3)
|
||||
std::cout
|
||||
<< " -gc,--generate_config Generate initial configuration"
|
||||
<< std::endl;
|
||||
std::cout << " -get,--get [name] Get configuration value"
|
||||
<< std::endl;
|
||||
std::cout << " -gdi,--get_directory_items Get directory list in "
|
||||
"json format"
|
||||
<< std::endl
|
||||
<< " [API path]" << std::endl;
|
||||
std::cout
|
||||
<< " -gpf,--get_pinned_files Get a list of all pinned files"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -nc Force disable console output"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -of,--open_files List all open files and count"
|
||||
<< std::endl;
|
||||
std::cout << " -rm,--remote_mount [host/ip:port] Enables remote mount mode"
|
||||
<< std::endl;
|
||||
std::cout << " -pf,--pin_file [API path] Pin a file to cache to "
|
||||
"prevent eviction"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -ps,--pinned_status [API path] Return pinned status for a file"
|
||||
<< std::endl;
|
||||
std::cout << " -pw,--password Specify API password"
|
||||
<< std::endl;
|
||||
#ifndef _WIN32
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
std::cout << " -o s3 Enables S3 mode for "
|
||||
"'fstab' mounts"
|
||||
<< std::endl;
|
||||
#endif // defined(REPERTORY_ENABLE_S3)
|
||||
#endif // _WIN32
|
||||
std::cout << " -set,--set [name] [value] Set configuration value"
|
||||
<< std::endl;
|
||||
std::cout << " -status Display mount status"
|
||||
<< std::endl;
|
||||
std::cout << " -unmount,--unmount Unmount and shutdown"
|
||||
<< std::endl;
|
||||
std::cout << " -uf,--unpin_file [API path] Unpin a file from cache "
|
||||
"to allow eviction"
|
||||
<< std::endl;
|
||||
std::cout << " -us,--user Specify API user name"
|
||||
<< std::endl;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_HELP_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_HELP_HPP_
|
||||
#define INCLUDE_CLI_HELP_HPP_
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
template <typename drive> inline void help(std::vector<const char *> args) {
|
||||
drive::display_options(args);
|
||||
std::cout << "Repertory options:" << std::endl;
|
||||
std::cout << " -cv,--check_version Check daemon version "
|
||||
"compatibility"
|
||||
<< std::endl;
|
||||
std::cout << " -dc,--display_config Display configuration"
|
||||
<< std::endl;
|
||||
std::cout << " -dd,--data_directory [directory] Override data directory"
|
||||
<< std::endl;
|
||||
std::cout << " -di,--drive_information Display mounted drive "
|
||||
"information"
|
||||
<< std::endl;
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
std::cout << " -s3,--s3 Enables S3 mode"
|
||||
<< std::endl;
|
||||
std::cout << " -na,--name Unique name for S3 "
|
||||
"instance [Required]"
|
||||
<< std::endl;
|
||||
#endif // defined(REPERTORY_ENABLE_S3)
|
||||
std::cout
|
||||
<< " -gc,--generate_config Generate initial configuration"
|
||||
<< std::endl;
|
||||
std::cout << " -get,--get [name] Get configuration value"
|
||||
<< std::endl;
|
||||
std::cout << " -gdi,--get_directory_items Get directory list in "
|
||||
"json format"
|
||||
<< std::endl
|
||||
<< " [API path]" << std::endl;
|
||||
std::cout
|
||||
<< " -gpf,--get_pinned_files Get a list of all pinned files"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -nc Force disable console output"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -of,--open_files List all open files and count"
|
||||
<< std::endl;
|
||||
std::cout << " -rm,--remote_mount [host/ip:port] Enables remote mount mode"
|
||||
<< std::endl;
|
||||
std::cout << " -pf,--pin_file [API path] Pin a file to cache to "
|
||||
"prevent eviction"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -ps,--pinned_status [API path] Return pinned status for a file"
|
||||
<< std::endl;
|
||||
std::cout << " -pw,--password Specify API password"
|
||||
<< std::endl;
|
||||
#ifndef _WIN32
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
std::cout << " -o s3 Enables S3 mode for "
|
||||
"'fstab' mounts"
|
||||
<< std::endl;
|
||||
#endif // defined(REPERTORY_ENABLE_S3)
|
||||
#endif // _WIN32
|
||||
std::cout << " -set,--set [name] [value] Set configuration value"
|
||||
<< std::endl;
|
||||
std::cout << " -status Display mount status"
|
||||
<< std::endl;
|
||||
std::cout << " -unmount,--unmount Unmount and shutdown"
|
||||
<< std::endl;
|
||||
std::cout << " -uf,--unpin_file [API path] Unpin a file from cache "
|
||||
"to allow eviction"
|
||||
<< std::endl;
|
||||
std::cout << " -us,--user Specify API user name"
|
||||
<< std::endl;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_HELP_HPP_
|
||||
|
@@ -1,179 +1,179 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_MOUNT_HPP_
|
||||
#define INCLUDE_CLI_MOUNT_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "providers/i_provider.hpp"
|
||||
#include "providers/provider.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
#include "utils/com_init_wrapper.hpp"
|
||||
#include "utils/file_utils.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "drives/winfsp/remotewinfsp/remote_client.hpp"
|
||||
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
|
||||
#include "drives/winfsp/winfsp_drive.hpp"
|
||||
|
||||
using repertory_drive = repertory::winfsp_drive;
|
||||
using remote_client = repertory::remote_winfsp::remote_client;
|
||||
using remote_drive = repertory::remote_winfsp::remote_winfsp_drive;
|
||||
using remote_instance = repertory::remote_winfsp::i_remote_instance;
|
||||
#else
|
||||
#include "drives/fuse/fuse_drive.hpp"
|
||||
#include "drives/fuse/remotefuse/remote_client.hpp"
|
||||
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
|
||||
|
||||
using repertory_drive = repertory::fuse_drive;
|
||||
using remote_client = repertory::remote_fuse::remote_client;
|
||||
using remote_drive = repertory::remote_fuse::remote_fuse_drive;
|
||||
using remote_instance = repertory::remote_fuse::i_remote_instance;
|
||||
#endif
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
mount(std::vector<const char *> args, std::string data_directory,
|
||||
int &mount_result, provider_type prov, const std::string &remote_host,
|
||||
std::uint16_t remote_port, const std::string &unique_id) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock();
|
||||
if (res == lock_result::locked) {
|
||||
ret = exit_code::mount_active;
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " mount is already active" << std::endl;
|
||||
} else if (res == lock_result::success) {
|
||||
const auto generate_config = utils::cli::has_option(
|
||||
args, utils::cli::options::generate_config_option);
|
||||
if (generate_config) {
|
||||
app_config config(prov, data_directory);
|
||||
if (prov == provider_type::remote) {
|
||||
config.set_enable_remote_mount(false);
|
||||
config.set_is_remote_mount(true);
|
||||
config.set_remote_host_name_or_ip(remote_host);
|
||||
config.set_remote_port(remote_port);
|
||||
config.save();
|
||||
}
|
||||
std::cout << "Generated " << app_config::get_provider_display_name(prov)
|
||||
<< " Configuration" << std::endl;
|
||||
std::cout << config.get_config_file_path() << std::endl;
|
||||
ret = utils::file::is_file(config.get_config_file_path())
|
||||
? exit_code::success
|
||||
: exit_code::file_creation_failed;
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
if (utils::cli::has_option(args, utils::cli::options::hidden_option)) {
|
||||
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
|
||||
}
|
||||
#endif
|
||||
const auto drive_args =
|
||||
utils::cli::parse_drive_options(args, prov, data_directory);
|
||||
app_config config(prov, data_directory);
|
||||
#ifdef _WIN32
|
||||
if (config.get_enable_mount_manager() &&
|
||||
not utils::is_process_elevated()) {
|
||||
com_init_wrapper cw;
|
||||
if (not lock.set_mount_state(true, "elevating", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
lock.release();
|
||||
|
||||
mount_result = utils::run_process_elevated(args);
|
||||
lock_data lock2(prov, unique_id);
|
||||
if (lock2.grab_lock() == lock_result::success) {
|
||||
if (not lock2.set_mount_state(false, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
lock2.release();
|
||||
}
|
||||
|
||||
return exit_code::mount_result;
|
||||
}
|
||||
#endif
|
||||
std::cout << "Initializing "
|
||||
<< app_config::get_provider_display_name(prov)
|
||||
<< (unique_id.empty() ? ""
|
||||
: (prov == provider_type::s3)
|
||||
? " [" + unique_id + ']'
|
||||
: " [" + remote_host + ':' +
|
||||
std::to_string(remote_port) + ']')
|
||||
<< " Drive" << std::endl;
|
||||
if (prov == provider_type::remote) {
|
||||
std::uint16_t port{0U};
|
||||
if (utils::get_next_available_port(config.get_api_port(), port)) {
|
||||
config.set_remote_host_name_or_ip(remote_host);
|
||||
config.set_remote_port(remote_port);
|
||||
config.set_api_port(port);
|
||||
config.set_is_remote_mount(true);
|
||||
config.set_enable_remote_mount(false);
|
||||
config.save();
|
||||
try {
|
||||
remote_drive drive(
|
||||
config,
|
||||
[&config]() -> std::unique_ptr<remote_instance> {
|
||||
return std::unique_ptr<remote_instance>(
|
||||
new remote_client(config));
|
||||
},
|
||||
lock);
|
||||
if (not lock.set_mount_state(true, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
mount_result = drive.mount(drive_args);
|
||||
ret = exit_code::mount_result;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "FATAL: " << e.what() << std::endl;
|
||||
ret = exit_code::startup_exception;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "FATAL: Unable to get available port" << std::endl;
|
||||
ret = exit_code::startup_exception;
|
||||
}
|
||||
} else {
|
||||
config.set_is_remote_mount(false);
|
||||
|
||||
try {
|
||||
auto provider = create_provider(prov, config);
|
||||
repertory_drive drive(config, lock, *provider);
|
||||
if (not lock.set_mount_state(true, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
mount_result = drive.mount(drive_args);
|
||||
ret = exit_code::mount_result;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "FATAL: " << e.what() << std::endl;
|
||||
ret = exit_code::startup_exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = exit_code::lock_failed;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_MOUNT_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_MOUNT_HPP_
|
||||
#define INCLUDE_CLI_MOUNT_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "providers/i_provider.hpp"
|
||||
#include "providers/provider.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
#include "utils/com_init_wrapper.hpp"
|
||||
#include "utils/file_utils.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "drives/winfsp/remotewinfsp/remote_client.hpp"
|
||||
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
|
||||
#include "drives/winfsp/winfsp_drive.hpp"
|
||||
|
||||
using repertory_drive = repertory::winfsp_drive;
|
||||
using remote_client = repertory::remote_winfsp::remote_client;
|
||||
using remote_drive = repertory::remote_winfsp::remote_winfsp_drive;
|
||||
using remote_instance = repertory::remote_winfsp::i_remote_instance;
|
||||
#else
|
||||
#include "drives/fuse/fuse_drive.hpp"
|
||||
#include "drives/fuse/remotefuse/remote_client.hpp"
|
||||
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
|
||||
|
||||
using repertory_drive = repertory::fuse_drive;
|
||||
using remote_client = repertory::remote_fuse::remote_client;
|
||||
using remote_drive = repertory::remote_fuse::remote_fuse_drive;
|
||||
using remote_instance = repertory::remote_fuse::i_remote_instance;
|
||||
#endif
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
mount(std::vector<const char *> args, std::string data_directory,
|
||||
int &mount_result, provider_type prov, const std::string &remote_host,
|
||||
std::uint16_t remote_port, const std::string &unique_id) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock();
|
||||
if (res == lock_result::locked) {
|
||||
ret = exit_code::mount_active;
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " mount is already active" << std::endl;
|
||||
} else if (res == lock_result::success) {
|
||||
const auto generate_config = utils::cli::has_option(
|
||||
args, utils::cli::options::generate_config_option);
|
||||
if (generate_config) {
|
||||
app_config config(prov, data_directory);
|
||||
if (prov == provider_type::remote) {
|
||||
config.set_enable_remote_mount(false);
|
||||
config.set_is_remote_mount(true);
|
||||
config.set_remote_host_name_or_ip(remote_host);
|
||||
config.set_remote_port(remote_port);
|
||||
config.save();
|
||||
}
|
||||
std::cout << "Generated " << app_config::get_provider_display_name(prov)
|
||||
<< " Configuration" << std::endl;
|
||||
std::cout << config.get_config_file_path() << std::endl;
|
||||
ret = utils::file::is_file(config.get_config_file_path())
|
||||
? exit_code::success
|
||||
: exit_code::file_creation_failed;
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
if (utils::cli::has_option(args, utils::cli::options::hidden_option)) {
|
||||
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
|
||||
}
|
||||
#endif
|
||||
const auto drive_args =
|
||||
utils::cli::parse_drive_options(args, prov, data_directory);
|
||||
app_config config(prov, data_directory);
|
||||
#ifdef _WIN32
|
||||
if (config.get_enable_mount_manager() &&
|
||||
not utils::is_process_elevated()) {
|
||||
com_init_wrapper cw;
|
||||
if (not lock.set_mount_state(true, "elevating", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
lock.release();
|
||||
|
||||
mount_result = utils::run_process_elevated(args);
|
||||
lock_data lock2(prov, unique_id);
|
||||
if (lock2.grab_lock() == lock_result::success) {
|
||||
if (not lock2.set_mount_state(false, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
lock2.release();
|
||||
}
|
||||
|
||||
return exit_code::mount_result;
|
||||
}
|
||||
#endif
|
||||
std::cout << "Initializing "
|
||||
<< app_config::get_provider_display_name(prov)
|
||||
<< (unique_id.empty() ? ""
|
||||
: (prov == provider_type::s3)
|
||||
? " [" + unique_id + ']'
|
||||
: " [" + remote_host + ':' +
|
||||
std::to_string(remote_port) + ']')
|
||||
<< " Drive" << std::endl;
|
||||
if (prov == provider_type::remote) {
|
||||
std::uint16_t port{0U};
|
||||
if (utils::get_next_available_port(config.get_api_port(), port)) {
|
||||
config.set_remote_host_name_or_ip(remote_host);
|
||||
config.set_remote_port(remote_port);
|
||||
config.set_api_port(port);
|
||||
config.set_is_remote_mount(true);
|
||||
config.set_enable_remote_mount(false);
|
||||
config.save();
|
||||
try {
|
||||
remote_drive drive(
|
||||
config,
|
||||
[&config]() -> std::unique_ptr<remote_instance> {
|
||||
return std::unique_ptr<remote_instance>(
|
||||
new remote_client(config));
|
||||
},
|
||||
lock);
|
||||
if (not lock.set_mount_state(true, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
mount_result = drive.mount(drive_args);
|
||||
ret = exit_code::mount_result;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "FATAL: " << e.what() << std::endl;
|
||||
ret = exit_code::startup_exception;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "FATAL: Unable to get available port" << std::endl;
|
||||
ret = exit_code::startup_exception;
|
||||
}
|
||||
} else {
|
||||
config.set_is_remote_mount(false);
|
||||
|
||||
try {
|
||||
auto provider = create_provider(prov, config);
|
||||
repertory_drive drive(config, lock, *provider);
|
||||
if (not lock.set_mount_state(true, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
mount_result = drive.mount(drive_args);
|
||||
ret = exit_code::mount_result;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "FATAL: " << e.what() << std::endl;
|
||||
ret = exit_code::startup_exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = exit_code::lock_failed;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_MOUNT_HPP_
|
||||
|
@@ -1,59 +1,59 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_OPEN_FILES_HPP_
|
||||
#define INCLUDE_CLI_OPEN_FILES_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
open_files(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user, std::string password)
|
||||
-> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_open_files();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " is not mounted." << std::endl;
|
||||
ret = exit_code::not_mounted;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_OPEN_FILES_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_OPEN_FILES_HPP_
|
||||
#define INCLUDE_CLI_OPEN_FILES_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
open_files(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user, std::string password)
|
||||
-> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_open_files();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " is not mounted." << std::endl;
|
||||
ret = exit_code::not_mounted;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_OPEN_FILES_HPP_
|
||||
|
@@ -1,57 +1,57 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_PIN_FILE_HPP_
|
||||
#define INCLUDE_CLI_PIN_FILE_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
pin_file(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /* unique_id */,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::pin_file_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).pin_file(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::pin_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_PIN_FILE_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_PIN_FILE_HPP_
|
||||
#define INCLUDE_CLI_PIN_FILE_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
pin_file(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /* unique_id */,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::pin_file_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).pin_file(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::pin_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_PIN_FILE_HPP_
|
||||
|
@@ -1,57 +1,57 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_PINNED_STATUS_HPP_
|
||||
#define INCLUDE_CLI_PINNED_STATUS_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
pinned_status(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::pinned_status_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).pinned_status(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::export_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_PINNED_STATUS_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_PINNED_STATUS_HPP_
|
||||
#define INCLUDE_CLI_PINNED_STATUS_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
pinned_status(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::pinned_status_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).pinned_status(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::export_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_PINNED_STATUS_HPP_
|
||||
|
@@ -1,80 +1,80 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_SET_HPP_
|
||||
#define INCLUDE_CLI_SET_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto set(std::vector<const char *> args,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto data = utils::cli::parse_option(args, "-set", 2U);
|
||||
if (data.empty()) {
|
||||
data = utils::cli::parse_option(args, "--set", 2U);
|
||||
if (data.empty()) {
|
||||
ret = exit_code::invalid_syntax;
|
||||
std::cerr << "Invalid syntax for '-set'" << std::endl;
|
||||
}
|
||||
}
|
||||
if (ret == exit_code::success) {
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(prov, data_directory);
|
||||
const auto value = config.set_value_by_name(data[0U], data[1U]);
|
||||
const auto notFound = value.empty() && not data[1U].empty();
|
||||
ret = notFound ? exit_code::set_option_not_found : exit_code::success;
|
||||
std::cout << (notFound ? static_cast<int>(
|
||||
rpc_response_type::config_value_not_found)
|
||||
: 0)
|
||||
<< std::endl;
|
||||
std::cout << json({{"value", value}}).dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user})
|
||||
.set_config_value_by_name(data[0U], data[1U]);
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
ret = response.response_type == rpc_response_type::config_value_not_found
|
||||
? exit_code::set_option_not_found
|
||||
: response.response_type == rpc_response_type::success
|
||||
? exit_code::success
|
||||
: exit_code::communication_error;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_SET_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_SET_HPP_
|
||||
#define INCLUDE_CLI_SET_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto set(std::vector<const char *> args,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto data = utils::cli::parse_option(args, "-set", 2U);
|
||||
if (data.empty()) {
|
||||
data = utils::cli::parse_option(args, "--set", 2U);
|
||||
if (data.empty()) {
|
||||
ret = exit_code::invalid_syntax;
|
||||
std::cerr << "Invalid syntax for '-set'" << std::endl;
|
||||
}
|
||||
}
|
||||
if (ret == exit_code::success) {
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(prov, data_directory);
|
||||
const auto value = config.set_value_by_name(data[0U], data[1U]);
|
||||
const auto notFound = value.empty() && not data[1U].empty();
|
||||
ret = notFound ? exit_code::set_option_not_found : exit_code::success;
|
||||
std::cout << (notFound ? static_cast<int>(
|
||||
rpc_response_type::config_value_not_found)
|
||||
: 0)
|
||||
<< std::endl;
|
||||
std::cout << json({{"value", value}}).dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user})
|
||||
.set_config_value_by_name(data[0U], data[1U]);
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
ret = response.response_type == rpc_response_type::config_value_not_found
|
||||
? exit_code::set_option_not_found
|
||||
: response.response_type == rpc_response_type::success
|
||||
? exit_code::success
|
||||
: exit_code::communication_error;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_SET_HPP_
|
||||
|
@@ -1,50 +1,50 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_STATUS_HPP_
|
||||
#define INCLUDE_CLI_STATUS_HPP_
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto status(std::vector<const char *> /* args */,
|
||||
const std::string & /*data_directory*/,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id,
|
||||
std::string /* user */,
|
||||
std::string /* password */) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
lock_data lock(prov, unique_id);
|
||||
[[maybe_unused]] auto status = lock.grab_lock(10U);
|
||||
json mount_state;
|
||||
if (lock.get_mount_state(mount_state)) {
|
||||
std::cout << mount_state.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cout << "{}" << std::endl;
|
||||
ret = exit_code::failed_to_get_mount_state;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_STATUS_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_STATUS_HPP_
|
||||
#define INCLUDE_CLI_STATUS_HPP_
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto status(std::vector<const char *> /* args */,
|
||||
const std::string & /*data_directory*/,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id,
|
||||
std::string /* user */,
|
||||
std::string /* password */) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
lock_data lock(prov, unique_id);
|
||||
[[maybe_unused]] auto status = lock.grab_lock(10U);
|
||||
json mount_state;
|
||||
if (lock.get_mount_state(mount_state)) {
|
||||
std::cout << mount_state.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cout << "{}" << std::endl;
|
||||
ret = exit_code::failed_to_get_mount_state;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_STATUS_HPP_
|
||||
|
@@ -1,53 +1,53 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_UNMOUNT_HPP_
|
||||
#define INCLUDE_CLI_UNMOUNT_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
unmount(std::vector<const char *> /* args */, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user}).unmount();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::communication_error;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_UNMOUNT_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_UNMOUNT_HPP_
|
||||
#define INCLUDE_CLI_UNMOUNT_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
unmount(std::vector<const char *> /* args */, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user}).unmount();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::communication_error;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_UNMOUNT_HPP_
|
||||
|
@@ -1,57 +1,57 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_UNPIN_FILE_HPP_
|
||||
#define INCLUDE_CLI_UNPIN_FILE_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
unpin_file(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::unpin_file_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).unpin_file(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::unpin_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_UNPIN_FILE_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_UNPIN_FILE_HPP_
|
||||
#define INCLUDE_CLI_UNPIN_FILE_HPP_
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "rpc/client/client.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "types/rpc.hpp"
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
unpin_file(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
args, repertory::utils::cli::options::unpin_file_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).unpin_file(data);
|
||||
if (response.response_type == rpc_response_type::success) {
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << response.data.dump(2) << std::endl;
|
||||
ret = exit_code::unpin_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_UNPIN_FILE_HPP_
|
||||
|
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_VERSION_HPP_
|
||||
#define INCLUDE_CLI_VERSION_HPP_
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
template <typename drive> inline void version(std::vector<const char *> args) {
|
||||
std::cout << "Repertory core version: " << get_repertory_version()
|
||||
<< std::endl;
|
||||
std::cout << "Repertory Git revision: " << get_repertory_git_revision()
|
||||
<< std::endl;
|
||||
drive::display_version_information(args);
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_VERSION_HPP_
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef INCLUDE_CLI_VERSION_HPP_
|
||||
#define INCLUDE_CLI_VERSION_HPP_
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
template <typename drive> inline void version(std::vector<const char *> args) {
|
||||
std::cout << "Repertory core version: " << get_repertory_version()
|
||||
<< std::endl;
|
||||
std::cout << "Repertory Git revision: " << get_repertory_git_revision()
|
||||
<< std::endl;
|
||||
drive::display_version_information(args);
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
#endif // INCLUDE_CLI_VERSION_HPP_
|
||||
|
Reference in New Issue
Block a user