#include "shell.h" #include "parser.h" //--- // . //--- static std::vector parse_dot(Session &, Parser &parser) { std::vector files; while(!parser.at_end()) files.push_back(parser.str()); return files; } void _dot(Session &s, std::vector const &files, bool absolute) { std::vector paths; for(auto const &file: files) { paths.push_back(absolute ? file : s.file(file).string()); } lex_include(paths); } //--- // .dt //--- static std::string parse_dot_dt(Session &session, Parser &parser) { std::string filename = parser.str(); parser.end(); return session.file(filename); } void _dot_dt(Session &, std::string filename) { Buffer buf(filename); FxOS::load_instructions(buf); } //--- // Command registration //--- static ShellCommand _dot_cmd( ".", [](Session &s, Parser &p) { _dot(s, parse_dot(s, p), false); }, [](Session &s, Parser &p) { parse_dot(s, p); }, "Include scripts", R"( . "" ""... Reads file paths from its string arguments, and executes each of them as a sequence of commands in the order of the command line. )"); static ShellCommand _dot_dt_cmd( ".dt", [](Session &s, Parser &p) { _dot_dt(s, parse_dot_dt(s, p)); }, [](Session &s, Parser &p) { parse_dot_dt(s, p); }, "Include Disassembly Table", R"( .dt "" Loads a disassembly table from the specified file. This command is mostly designed to be used in startup scripts. )");