From 90830c13b6a143f1c370a2007100d2fdb069a090 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 11 Feb 2026 16:53:12 +0100 Subject: Dangling changes. no clue when this happened --- kel_cmds/c++/cmd_schema.hpp | 16 ++++++++--- kel_cmds/c++/common.hpp | 7 +++++ kel_cmds/c++/kel_cmds.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 kel_cmds/c++/common.hpp diff --git a/kel_cmds/c++/cmd_schema.hpp b/kel_cmds/c++/cmd_schema.hpp index 472fd9b..3d50079 100644 --- a/kel_cmds/c++/cmd_schema.hpp +++ b/kel_cmds/c++/cmd_schema.hpp @@ -6,14 +6,22 @@ namespace kel { namespace sch { using namespace saw::schema; +using CommandIoAddress = String; + using CommandStruct = Struct< - Member, "command"> + Member, "exec"> >; -using Commands = Struct< - +using CommandAsyncGroup = Struct< + Member, "commands"> >; -} +using CommandSequenceGroup = Struct< + Member, "async_commands"> +>; +using CommandConfig = Struct< + Member, "sequences"> +>; +} } diff --git a/kel_cmds/c++/common.hpp b/kel_cmds/c++/common.hpp new file mode 100644 index 0000000..79e3bbb --- /dev/null +++ b/kel_cmds/c++/common.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace kel { + +} diff --git a/kel_cmds/c++/kel_cmds.cpp b/kel_cmds/c++/kel_cmds.cpp index b7ea512..1ced1a9 100644 --- a/kel_cmds/c++/kel_cmds.cpp +++ b/kel_cmds/c++/kel_cmds.cpp @@ -2,8 +2,75 @@ #include +#include "common.hpp" + namespace kel { +namespace sch { +using namespace saw::schema; + +using CmdArgs = Args< + Struct< + >, + Tuple<> +>; +} + + saw::error_or kel_main(int argc, char** argv){ + saw::data args_d; + { + saw::data args_data{argc, argv}; + saw::codec args_codec; + + auto eov = args_codec.decode(args_data, args_d); + if(eov.is_error()){ + return eov; + } + } + saw::data cmd_data; + { + // Parse from file + } + + bool running = true; + while(running){ + std::array buffer; + std::cin.getline(&buffer[0],buffer.size()); + if(std::cin.bad()){ + return saw::make_error("unrecoverable stdin error"); + } + if(std::cin.fail()){ + return saw::make_error("stdin format error or line too long"); + } + if(std::cin.eof()){ + return saw::make_error("stdin EOF"); + } + + const std::string_view cmd{buffer.data()}; + + { + auto eov = print_cmd_options(); + if(eov.is_error()){ + return eov; + } + } + + if(cmd == "q" or cmd == "quit"){ + running = false; + std::cout<<"Quitting..."; + }else { + uint16_t cmd_id{}; + auto res = std::from_chars(cmd.data(), cmd.data() + cmd.size(), cmd_id); + if(res.ec == std::errc{} and res.ptr == (cmd.data() + cmd.size())){ + auto eov = execute_command_group(cmd_data, cmd_id); + if(eov.is_error()){ + return eov; + } + }else{ + std::cout<<"Failed to parse input as uint16\nRepeat input..."<