From 8cc9454438e2e4fb6729c87e331dbe5fa6b5d671 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 3 May 2014 15:58:13 +0100 Subject: [PATCH] Add a -alias switch to the def command for defining an alias Fixes #100 --- src/commands.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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