chore(furdb): initialize furdb

This commit is contained in:
2026-08-12 14:17:16 +02:00
parent c68763f785
commit d419b62225
7 changed files with 222 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
#include "command.hpp"
#include <cctype>
#include <cstddef>
#include <iostream>
#include <random>
#include <utility>
command_info command::parse(std::string_view line) {
command_info info;
while (!line.empty() && std::isspace(line.front()) != 0)
line = line.substr(1);
std::size_t length = 0;
while (line.size() > length && std::isalnum(line.at(length)) != 0)
++length;
info.commandName = line.substr(0, length);
line = line.substr(length);
while (true) {
while (!line.empty() && std::isspace(line.front()) != 0)
line = line.substr(1);
if (line.empty()) break;
length = 0;
while (line.size() > length && std::isalnum(line.at(length)) != 0)
++length;
info.args.push_back(line.substr(0, length));
line = line.substr(length);
}
return std::move(info);
}
void quit_command::execute(context& ctx, const command_info& info) {
static std::random_device s_rd;
static std::mt19937 s_gen(s_rd());
static std::uniform_int_distribution<> s_dis(1, 1000);
int roll = s_dis(s_gen);
std::cout << "Farewell";
if (roll == 1) {
std::cout << ", stasiu pensive";
} else if (roll <= 100) {
std::cout << ", kromek-man";
}
std::cout << "!\n";
ctx.running = false;
}
void run_command::execute(context& ctx, const command_info& info) {
ctx.run();
std::cout << "Execution finished\n";
}