CommandManager: tweak naming
This commit is contained in:
parent
7f51e51fcb
commit
6bac767124
|
@ -22,14 +22,14 @@ bool CommandManager::command_defined(StringView command_name) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandManager::register_command(String command_name,
|
void CommandManager::register_command(String command_name,
|
||||||
Command command,
|
CommandFunc func,
|
||||||
String docstring,
|
String docstring,
|
||||||
ParameterDesc param_desc,
|
ParameterDesc param_desc,
|
||||||
CommandFlags flags,
|
CommandFlags flags,
|
||||||
CommandHelper helper,
|
CommandHelper helper,
|
||||||
CommandCompleter completer)
|
CommandCompleter completer)
|
||||||
{
|
{
|
||||||
m_commands[command_name] = { std::move(command),
|
m_commands[command_name] = { std::move(func),
|
||||||
std::move(docstring),
|
std::move(docstring),
|
||||||
std::move(param_desc),
|
std::move(param_desc),
|
||||||
flags,
|
flags,
|
||||||
|
@ -411,8 +411,8 @@ String expand(StringView str, const Context& context,
|
||||||
|
|
||||||
struct command_not_found : runtime_error
|
struct command_not_found : runtime_error
|
||||||
{
|
{
|
||||||
command_not_found(StringView command)
|
command_not_found(StringView name)
|
||||||
: runtime_error(command + " : no such command") {}
|
: runtime_error(name + " : no such command") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
CommandManager::CommandMap::const_iterator
|
CommandManager::CommandMap::const_iterator
|
||||||
|
@ -458,7 +458,7 @@ void CommandManager::execute_single_command(CommandParameters params,
|
||||||
{
|
{
|
||||||
ParametersParser parameter_parser(param_view,
|
ParametersParser parameter_parser(param_view,
|
||||||
command_it->value.param_desc);
|
command_it->value.param_desc);
|
||||||
command_it->value.command(parameter_parser, context, shell_context);
|
command_it->value.func(parameter_parser, context, shell_context);
|
||||||
}
|
}
|
||||||
catch (runtime_error& error)
|
catch (runtime_error& error)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Kakoune
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
using CommandParameters = ConstArrayView<String>;
|
using CommandParameters = ConstArrayView<String>;
|
||||||
using Command = std::function<void (const ParametersParser& parser,
|
using CommandFunc = std::function<void (const ParametersParser& parser,
|
||||||
Context& context,
|
Context& context,
|
||||||
const ShellContext& shell_context)>;
|
const ShellContext& shell_context)>;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
|
|
||||||
bool command_defined(StringView command_name) const;
|
bool command_defined(StringView command_name) const;
|
||||||
|
|
||||||
void register_command(String command_name, Command command,
|
void register_command(String command_name, CommandFunc func,
|
||||||
String docstring,
|
String docstring,
|
||||||
ParameterDesc param_desc,
|
ParameterDesc param_desc,
|
||||||
CommandFlags flags = CommandFlags::None,
|
CommandFlags flags = CommandFlags::None,
|
||||||
|
@ -101,16 +101,16 @@ private:
|
||||||
const ShellContext& shell_context,
|
const ShellContext& shell_context,
|
||||||
DisplayCoord pos);
|
DisplayCoord pos);
|
||||||
|
|
||||||
struct CommandDescriptor
|
struct Command
|
||||||
{
|
{
|
||||||
Command command;
|
CommandFunc func;
|
||||||
String docstring;
|
String docstring;
|
||||||
ParameterDesc param_desc;
|
ParameterDesc param_desc;
|
||||||
CommandFlags flags;
|
CommandFlags flags;
|
||||||
CommandHelper helper;
|
CommandHelper helper;
|
||||||
CommandCompleter completer;
|
CommandCompleter completer;
|
||||||
};
|
};
|
||||||
using CommandMap = HashMap<String, CommandDescriptor, MemoryDomain::Commands>;
|
using CommandMap = HashMap<String, Command, MemoryDomain::Commands>;
|
||||||
CommandMap m_commands;
|
CommandMap m_commands;
|
||||||
String m_last_complete_command;
|
String m_last_complete_command;
|
||||||
int m_command_depth = 0;
|
int m_command_depth = 0;
|
||||||
|
|
|
@ -845,7 +845,7 @@ void define_command(const ParametersParser& parser, Context& context, const Shel
|
||||||
flags = CommandFlags::Hidden;
|
flags = CommandFlags::Hidden;
|
||||||
|
|
||||||
const String& commands = parser[1];
|
const String& commands = parser[1];
|
||||||
Command cmd;
|
CommandFunc cmd;
|
||||||
ParameterDesc desc;
|
ParameterDesc desc;
|
||||||
if (auto params = parser.get_switch("params"))
|
if (auto params = parser.get_switch("params"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user