fxos/shell/dot.cpp

39 lines
885 B
C++

#include "shell.h"
#include "parser.h"
//---
// .
//---
static std::vector<std::string> parse_dot(Session &, Parser &parser)
{
std::vector<std::string> files;
while(!parser.at_end())
files.push_back(parser.str());
return files;
}
void _dot(Session &s, std::vector<std::string> const &files, bool absolute)
{
std::vector<std::string> paths;
for(auto const &file: files) {
paths.push_back(absolute ? file : s.file(file).string());
}
lex_include(paths);
}
//---
// 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"(
. "<script_1>" "<script_2>"...
Reads file paths from its string arguments, and executes each of them as a
sequence of commands in the order of the command line.
)");