CommandManager: support ';' as a command separator
This commit is contained in:
parent
c76b44e91d
commit
4a5758ebb3
|
@ -41,12 +41,15 @@ static TokenList split(const std::string& line)
|
||||||
|
|
||||||
size_t token_start = pos;
|
size_t token_start = pos;
|
||||||
|
|
||||||
while ((line[pos] != delimiter or line[pos-1] == '\\') and
|
while (((line[pos] != delimiter and line[pos] != ';') or
|
||||||
pos != line.length())
|
line[pos-1] == '\\') and pos != line.length())
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
result.push_back(std::make_pair(token_start, pos));
|
result.push_back(std::make_pair(token_start, pos));
|
||||||
|
|
||||||
|
if (line[pos] == ';')
|
||||||
|
result.push_back(std::make_pair(pos, pos+1));
|
||||||
|
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -81,11 +84,28 @@ void CommandManager::execute(const CommandParameters& params,
|
||||||
if (params.empty())
|
if (params.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto command_it = m_commands.find(params[0]);
|
auto begin = params.begin();
|
||||||
if (command_it == m_commands.end())
|
auto end = begin;
|
||||||
throw command_not_found(params[0]);
|
while (true)
|
||||||
|
{
|
||||||
|
while (end != params.end() and *end != ";")
|
||||||
|
++end;
|
||||||
|
|
||||||
command_it->second.command(CommandParameters(params.begin() + 1, params.end()), context);
|
if (end != begin)
|
||||||
|
{
|
||||||
|
auto command_it = m_commands.find(*begin);
|
||||||
|
if (command_it == m_commands.end())
|
||||||
|
throw command_not_found(*begin);
|
||||||
|
|
||||||
|
command_it->second.command(CommandParameters(begin + 1, end), context);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end == params.end())
|
||||||
|
break;
|
||||||
|
|
||||||
|
begin = end+1;
|
||||||
|
end = begin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Completions CommandManager::complete(const std::string& command_line, size_t cursor_pos)
|
Completions CommandManager::complete(const std::string& command_line, size_t cursor_pos)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user