command_manager.cc: use anonymous namespace
This commit is contained in:
parent
2d2ac98511
commit
407782a742
|
@ -30,6 +30,9 @@ void CommandManager::register_commands(const memoryview<String>& command_names,
|
||||||
register_command(command_name, command, completer);
|
register_command(command_name, command, completer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
struct Token
|
struct Token
|
||||||
{
|
{
|
||||||
enum class Type
|
enum class Type
|
||||||
|
@ -57,17 +60,17 @@ private:
|
||||||
using TokenList = std::vector<Token>;
|
using TokenList = std::vector<Token>;
|
||||||
using TokenPosList = std::vector<std::pair<size_t, size_t>>;
|
using TokenPosList = std::vector<std::pair<size_t, size_t>>;
|
||||||
|
|
||||||
static bool is_command_separator(Character c)
|
bool is_command_separator(Character c)
|
||||||
{
|
{
|
||||||
return c == ';' or c == '\n';
|
return c == ';' or c == '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_horizontal_blank(char c)
|
bool is_horizontal_blank(char c)
|
||||||
{
|
{
|
||||||
return c == ' ' or c == '\t';
|
return c == ' ' or c == '\t';
|
||||||
}
|
}
|
||||||
|
|
||||||
static TokenList parse(const String& line,
|
TokenList parse(const String& line,
|
||||||
TokenPosList* opt_token_pos_info = NULL)
|
TokenPosList* opt_token_pos_info = NULL)
|
||||||
{
|
{
|
||||||
TokenList result;
|
TokenList result;
|
||||||
|
@ -169,10 +172,8 @@ static TokenList parse(const String& line,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shell_eval(TokenList& params,
|
void shell_eval(TokenList& params, const String& cmdline,
|
||||||
const String& cmdline,
|
const Context& context, const EnvVarMap& env_vars)
|
||||||
const Context& context,
|
|
||||||
const EnvVarMap& env_vars)
|
|
||||||
{
|
{
|
||||||
String output = ShellManager::instance().eval(cmdline, context, env_vars);
|
String output = ShellManager::instance().eval(cmdline, context, env_vars);
|
||||||
TokenList tokens = parse(output);
|
TokenList tokens = parse(output);
|
||||||
|
@ -181,6 +182,8 @@ static void shell_eval(TokenList& params,
|
||||||
params.push_back(std::move(token));
|
params.push_back(std::move(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
struct command_not_found : runtime_error
|
struct command_not_found : runtime_error
|
||||||
{
|
{
|
||||||
command_not_found(const String& command)
|
command_not_found(const String& command)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user