#include #include "GlobalDefs.h" #include "ComCtrl.h" #include "Noncanonical.h" using namespace std; // 全局命令存储 std::vector historyList{}; Send Sender; int main() { // 设置非规范终端模式 set_noncanonical_mode(); if (!Sender.isRunning()) { return 0; } cout << "CP Ctrl Console (v1.0)\nType 'exit' to quit" << endl; cout << "Type 'help' for available commands" << endl; while (true) { string input = readLine("> "); if (input.empty()) continue; // 处理输入 vector args; string token; for (char c: input) { if (isspace(c)) { if (!token.empty()) { args.push_back(token); token.clear(); } } else { token += c; } } if (!token.empty()) args.push_back(token); if (args.empty()) continue; string command = toLower(args[0]); if (command == "exit") { cout << "Exiting..." << endl; break; } else if (command == "setant") { setantCommand(args); } else if (command == "seteph") { setephCommand(args); } else if (command == "query") { queryCommand(args); } else if (command == "list") { listCommand(); } else if (command == "help") { cout << "Available commands:\n" << " setant - SetAnt key-value pair\n" << " seteph - SetEph key-value pair\n" << " query - query type-key value\n" << " list - history\n" << " exit - Exit program\n" << " help - Show this help\n\n" << "Tab completion available for commands and keys" << endl; } else { cout << "Invalid command: " << command << endl; cout << "Type 'help' for available commands" << endl; } } return 0; }