diff --git a/README.asciidoc b/README.asciidoc index a008feed..b5c82337 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -725,6 +725,7 @@ command `q!` has to be used). `:%sh{ echo echo tchou }` will echo tchou in Kakoune, whereas `:nop %sh{ echo echo tchou }` will not, but both will execute the shell command. + * `fail `: raise an error, uses as its description Multiple commands ~~~~~~~~~~~~~~~~~ diff --git a/doc/manpages/commands.asciidoc b/doc/manpages/commands.asciidoc index 1140841f..0123f090 100644 --- a/doc/manpages/commands.asciidoc +++ b/doc/manpages/commands.asciidoc @@ -96,6 +96,9 @@ command *q!* has to be used). Aliases are mentionned below each commands. *nop*:: does nothing, but arguments will be evaluated (e.g. shell expansion) +*fail* :: + raise an error, uses as its description + *declare-option* [-hidden] []:: *alias* decl + declare a new option, the -hidden hides the option in completion diff --git a/src/commands.cc b/src/commands.cc index 466a84dd..1593901e 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2105,6 +2105,20 @@ const CommandDesc rename_session_cmd = { } }; +const CommandDesc fail_cmd = { + "fail", + nullptr, + "fail []: raise an error with the given message", + ParameterDesc{}, + CommandFlags::None, + CommandHelper{}, + CommandCompleter{}, + [](const ParametersParser& parser, Context&, const ShellContext&) + { + throw runtime_error(fix_atom_text(join(parser, ' ', false))); + } +}; + } void register_commands() @@ -2166,6 +2180,7 @@ void register_commands() register_command(select_cmd); register_command(change_directory_cmd); register_command(rename_session_cmd); + register_command(fail_cmd); } }