mirror of
https://github.com/neovim/neovim.git
synced 2025-10-13 05:16:09 +00:00
api: Implement vim_command_output function
This function can be used by API clients to execute a command and capture the output.
This commit is contained in:

committed by
Justin M. Keyes

parent
c28adf15e6
commit
94f59fc9be
@@ -96,6 +96,19 @@ String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt,
|
||||
return cstr_as_string(ptr);
|
||||
}
|
||||
|
||||
String vim_command_output(String str, Error *err)
|
||||
{
|
||||
do_cmdline_cmd((char_u *)"redir => v:command_output");
|
||||
vim_command(str, err);
|
||||
do_cmdline_cmd((char_u *)"redir END");
|
||||
|
||||
if (err->set) {
|
||||
return (String) STRING_INIT;
|
||||
}
|
||||
|
||||
return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT));
|
||||
}
|
||||
|
||||
/// Evaluates the expression str using the vim internal expression
|
||||
/// evaluator (see |expression|).
|
||||
/// Dictionaries and lists are recursively expanded.
|
||||
|
Reference in New Issue
Block a user