memgraph/tests/manual/kvstore_console.cpp
Matej Ferencevic 44821a918c Initial implementation of telemetry
Summary:
Add telemetry to main memgraph binary

Add resource usage collector

Add telemetry flag

Change telemetry collector logic

Fix utils compilation

Add timestamp

Add first version of interactive test

Started working on test runner

Implement all tests

Flake8 on runner.py

Integrate test with Apollo

Add TODO

Reviewers: buda, teon.banek

Reviewed By: buda, teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1419
2018-06-20 14:49:07 +02:00

67 lines
1.9 KiB
C++

#include <gflags/gflags.h>
#include <glog/logging.h>
#include "storage/kvstore.hpp"
#include "utils/string.hpp"
DEFINE_string(path, "", "Path to the storage directory.");
int main(int argc, char **argv) {
gflags::SetVersionString("kvstore_console");
gflags::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
CHECK(FLAGS_path != "") << "Please specify a path to the KVStore!";
storage::KVStore kvstore(std::experimental::filesystem::path{FLAGS_path});
while (true) {
std::string s;
std::getline(std::cin, s);
if (s == "") {
break;
}
auto split = utils::Split(utils::Trim(s));
if (split[0] == "list") {
if (split.size() != 1) {
std::cout << "`list' takes no arguments!" << std::endl;
}
for (auto it = kvstore.begin(); it != kvstore.end(); ++it) {
std::cout << it->first << " --> " << it->second << std::endl;
}
} else if (split[0] == "get") {
if (split.size() != 2) {
std::cout << "`get' takes exactly one argument!" << std::endl;
}
auto item = kvstore.Get(split[1]);
if (item != std::experimental::nullopt) {
std::cout << split[1] << " --> " << *item << std::endl;
} else {
std::cout << "Key doesn't exist in the database!" << std::endl;
}
} else if (split[0] == "put") {
if (split.size() != 3) {
std::cout << "`put' takes exactly two arguments!" << std::endl;
}
if (kvstore.Put(split[1], split[2])) {
std::cout << "Success." << std::endl;
} else {
std::cout << "Failure!" << std::endl;
}
} else if (split[0] == "delete") {
if (split.size() != 2) {
std::cout << "`delete' takes exactly one argument!" << std::endl;
}
if (kvstore.Delete(split[1])) {
std::cout << "Success." << std::endl;
} else {
std::cout << "Failure!" << std::endl;
}
}
std::cout << std::endl;
}
return 0;
}