Skip to content
Snippets Groups Projects
Verified Commit a5b7293b authored by Timm Fitschen's avatar Timm Fitschen
Browse files

update cxxcaosdbcli

parent 3e3196e5
No related branches found
No related tags found
2 merge requests!42Release 0.2.0,!40F dot in username
Pipeline #24975 failed
......@@ -111,18 +111,18 @@ public:
*/
[[nodiscard]] auto ListRoles() const -> std::vector<Role>;
[[nodiscard]] auto RetrieveSingleRole(std::string name) const -> Role;
[[nodiscard]] auto RetrieveSingleRole(const std::string &name) const -> Role;
auto CreateSingleRole(const Role &role) const -> void;
auto DeleteSingleRole(std::string name) const -> void;
auto DeleteSingleRole(const std::string &name) const -> void;
/**
* Retrieve a single user.
*/
// TODO(tf) find a way to deal with this:
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
[[nodiscard]] auto RetrieveSingleUser(std::string realm, std::string name) const -> User;
[[nodiscard]] auto RetrieveSingleUser(const std::string &realm, const std::string &name) const -> User;
/**
* Create a new user.
......@@ -134,7 +134,7 @@ public:
*/
// TODO(tf) find a way to deal with this:
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
auto DeleteSingleUser(std::string realm, std::string name) const -> void;
auto DeleteSingleUser(const std::string &realm, const std::string &name) const -> void;
#endif
private:
......
......@@ -128,7 +128,7 @@ auto Connection::RetrieveVersionInfo() const -> const VersionInfo & {
}
#ifdef BUILD_ACM
[[nodiscard]] auto Connection::RetrieveSingleRole(std::string name) const -> Role {
[[nodiscard]] auto Connection::RetrieveSingleRole(const std::string &name) const -> Role {
RetrieveSingleRoleRequest request;
request.set_name(name);
RetrieveSingleRoleResponse response;
......@@ -156,7 +156,7 @@ auto Connection::RetrieveVersionInfo() const -> const VersionInfo & {
return Role(std::make_unique<RoleImpl>(role));
}
auto Connection::DeleteSingleRole(std::string name) const -> void {
auto Connection::DeleteSingleRole(const std::string &name) const -> void {
DeleteSingleRoleRequest request;
request.set_name(name);
DeleteSingleRoleResponse response;
......@@ -211,7 +211,7 @@ auto Connection::CreateSingleRole(const Role &role) const -> void {
// TODO(tf) find a way to deal with this:
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
[[nodiscard]] auto Connection::RetrieveSingleUser(std::string realm, std::string name) const
[[nodiscard]] auto Connection::RetrieveSingleUser(const std::string &realm, const std::string &name) const
-> User {
RetrieveSingleUserRequest request;
request.set_name(name);
......@@ -243,7 +243,7 @@ auto Connection::CreateSingleRole(const Role &role) const -> void {
// TODO(tf) find a way to deal with this:
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
auto Connection::DeleteSingleUser(std::string realm, std::string name) const -> void {
auto Connection::DeleteSingleUser(const std::string &realm, const std::string &name) const -> void {
DeleteSingleUserRequest request;
request.set_name(name);
request.set_realm(realm);
......
......@@ -21,6 +21,9 @@
*/
// A simple caosdb client
#ifdef BUILD_ACM
#include "caosdb/acm/role.h" // for Role
#endif
#include "caosdb/connection.h" // for Connection, ConnectionManager
#include "caosdb/constants.h" // for LIBCAOSDB_VERSION_MINOR, LIBCAOSDB_V...
#include "caosdb/entity.h" // for Entity
......@@ -34,6 +37,8 @@
#include <iostream> // for operator<<, basic_ostream, basic_ost...
#include <memory> // for unique_ptr, allocator, __shared_ptr_...
#include <string> // for operator<<, char_traits
#include <vector> // for vector
const auto logger_name = "libcaosdb";
......@@ -41,8 +46,6 @@ using boost::program_options::bool_switch;
using boost::program_options::command_line_parser;
using boost::program_options::notify;
using boost::program_options::options_description;
using boost::program_options::parse_command_line;
using boost::program_options::positional_options_description;
using boost::program_options::store;
using boost::program_options::value;
using boost::program_options::variables_map;
......@@ -70,7 +73,7 @@ auto test_connection() -> void {
<< std::endl;
}
auto retrieve_entity_by_id(std::string id) -> void {
auto retrieve_entity_by_id(const std::string &id) -> void {
std::cout << "Retrieve entity " << id << std::endl;
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
auto transaction(connection->CreateTransaction());
......@@ -85,7 +88,7 @@ auto retrieve_entity_by_id(std::string id) -> void {
}
}
auto execute_query(std::string query) -> void {
auto execute_query(const std::string &query) -> void {
std::cout << "Execute query:\n" << query << std::endl;
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
auto q_transaction(connection->CreateTransaction());
......@@ -105,25 +108,25 @@ auto list_roles() -> void {
std::cout << "Known roles:" << std::endl;
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
auto roles = connection->ListRoles();
for (const auto role : roles) {
for (const auto &role : roles) {
std::cout << role.ToString() << std::endl;
}
}
auto retrieve_role(std::string name) {
auto retrieve_role(const std::string &name) {
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
auto role = connection->RetrieveSingleRole(name);
std::cout << role.ToString() << std::endl;
}
auto create_role(std::string name) {
auto create_role(const std::string &name) {
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
Role role(name);
connection->CreateSingleRole(role);
connection->CreateSingleRole(name);
std::cout << "OK" << std::endl;
}
auto delete_role(std::string name) {
auto delete_role(const std::string &name) {
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
connection->DeleteSingleRole(name);
std::cout << "OK" << std::endl;
......@@ -164,16 +167,16 @@ auto main(int argc, const char *argv[]) -> int {
if (vm.count("help")) {
std::cout << desc << std::endl;
} else if (vm["version"].as<bool>()) {
} else if (vm.count("test-connection")) {
} else if (vm.count("test-connection") != 0U) {
test_connection();
#ifdef BUILD_ACM
} else if (vm.count("list-roles")) {
} else if (vm.count("list-roles") != 0U) {
list_roles();
} else if (vm.count("retrieve-role")) {
} else if (vm.count("retrieve")) {
} else if (vm.count("create-role")) {
} else if (vm.count("delete-role")) {
} else if (vm.count("execute-query")) {
} else if (vm.count("retrieve-role") != 0U) {
} else if (vm.count("retrieve")) != 0U {
} else if (vm.count("create-role") != 0U) {
} else if (vm.count("delete-role") != 0U) {
} else if (vm.count("execute-query") != 0U) {
#endif
} else {
print_version(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment