Add -docstring option to the 'def' command
used defined commands can have their own documentation strings
This commit is contained in:
parent
4b9d49d7ab
commit
aab390ab92
|
@ -789,6 +789,7 @@ def can also takes some flags:
|
||||||
* +-allow-override+: allow the new command to replace an exisiting one
|
* +-allow-override+: allow the new command to replace an exisiting one
|
||||||
with the same name.
|
with the same name.
|
||||||
* +-hidden+: do not show the command in command name completions
|
* +-hidden+: do not show the command in command name completions
|
||||||
|
* +-docstring+: define the documentation string for the command
|
||||||
|
|
||||||
Using shell expansion permits to define complex commands or to access
|
Using shell expansion permits to define complex commands or to access
|
||||||
Kakoune state:
|
Kakoune state:
|
||||||
|
|
|
@ -588,6 +588,10 @@ void define_command(const ParametersParser& parser, Context& context)
|
||||||
if (parser.has_option("hidden"))
|
if (parser.has_option("hidden"))
|
||||||
flags = CommandFlags::Hidden;
|
flags = CommandFlags::Hidden;
|
||||||
|
|
||||||
|
String docstring;
|
||||||
|
if (parser.has_option("docstring"))
|
||||||
|
docstring = parser.option_value("docstring");
|
||||||
|
|
||||||
String commands = parser[1];
|
String commands = parser[1];
|
||||||
Command cmd;
|
Command cmd;
|
||||||
ParameterDesc desc;
|
ParameterDesc desc;
|
||||||
|
@ -645,7 +649,7 @@ void define_command(const ParametersParser& parser, Context& context)
|
||||||
return Completions{ 0_byte, params[token_to_complete].length(), split(output, '\n') };
|
return Completions{ 0_byte, params[token_to_complete].length(), split(output, '\n') };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
CommandManager::instance().register_command(cmd_name, cmd, "", desc, flags, completer);
|
CommandManager::instance().register_command(cmd_name, cmd, std::move(docstring), desc, flags, completer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CommandDesc define_command_cmd = {
|
const CommandDesc define_command_cmd = {
|
||||||
|
@ -658,6 +662,7 @@ const CommandDesc define_command_cmd = {
|
||||||
{ "allow-override", { false, "allow overriding existing command" } },
|
{ "allow-override", { false, "allow overriding existing command" } },
|
||||||
{ "file-completion", { false, "complete parameters using filename completion" } },
|
{ "file-completion", { false, "complete parameters using filename completion" } },
|
||||||
{ "hidden", { false, "do not display the command as completion candidate" } },
|
{ "hidden", { false, "do not display the command as completion candidate" } },
|
||||||
|
{ "docstring", { true, "set docstring for command" } },
|
||||||
{ "shell-completion", { true, "complete the parameters using the given shell-script" } } },
|
{ "shell-completion", { true, "complete the parameters using the given shell-script" } } },
|
||||||
ParameterDesc::Flags::None,
|
ParameterDesc::Flags::None,
|
||||||
2, 2
|
2, 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user