summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-05-03 15:58:13 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-05-03 16:00:10 +0100
commit8cc9454438e2e4fb6729c87e331dbe5fa6b5d671 (patch)
treec65e4fb104a0560199bab45fdc6d00c26ebafdcf
parent5db3b51843c622ee40aa7683b6563923e1429244 (diff)
Add a -alias switch to the def command for defining an alias
Fixes #100
-rw-r--r--src/commands.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 714736bd..45c32382 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -648,7 +648,13 @@ void define_command(const ParametersParser& parser, Context& context)
return Completions{ 0_byte, params[token_to_complete].length(), split(output, '\n') };
};
}
- CommandManager::instance().register_command(cmd_name, cmd, std::move(docstring), desc, flags, completer);
+ if (parser.has_option("alias"))
+ CommandManager::instance().register_commands(
+ { cmd_name, parser.option_value("alias") },
+ cmd, std::move(docstring), desc, flags, completer);
+ else
+ CommandManager::instance().register_command(
+ cmd_name, cmd, std::move(docstring), desc, flags, completer);
}
const CommandDesc define_command_cmd = {
@@ -664,6 +670,7 @@ const CommandDesc define_command_cmd = {
{ "buffer-completion", { false, "complete parameters using buffer name completion" } },
{ "shell-completion", { true, "complete the parameters using the given shell-script" } },
{ "hidden", { false, "do not display the command as completion candidate" } },
+ { "alias", { true, "define an alias for this command" } },
{ "docstring", { true, "set docstring for command" } } },
ParameterDesc::Flags::None,
2, 2