summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2022-11-04 16:40:07 +1100
committerMaxime Coste <mawww@kakoune.org>2022-11-04 16:40:07 +1100
commitca6a701b8036db84fd149dceca665966748491a8 (patch)
treed9dafda2e033608a9afefb5753c404afcc4ad08c /src
parent98b84f2b05e8532703898a85abd06fc28c4e40ac (diff)
Add -to-shell-script echo switch
This feature simplifies various small use cases and is a good companion to the existing -to-file switch.
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 2efdf62a..660a2726 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -1427,13 +1427,14 @@ const CommandDesc echo_cmd = {
{ { "markup", { false, "parse markup" } },
{ "quoting", { true, "quote each argument separately using the given style (raw|kakoune|shell)" } },
{ "to-file", { true, "echo contents to given filename" } },
+ { "to-shell-script", { true, "pipe contents to given shell script" } },
{ "debug", { false, "write to debug buffer instead of status line" } } },
ParameterDesc::Flags::SwitchesOnlyAtStart
},
CommandFlags::None,
CommandHelper{},
CommandCompleter{},
- [](const ParametersParser& parser, Context& context, const ShellContext&)
+ [](const ParametersParser& parser, Context& context, const ShellContext& shell_context)
{
String message;
if (auto quoting = parser.get_switch("quoting"))
@@ -1443,9 +1444,10 @@ const CommandDesc echo_cmd = {
message = join(parser, ' ', false);
if (auto filename = parser.get_switch("to-file"))
- return write_to_file(*filename, message);
-
- if (parser.get_switch("debug"))
+ write_to_file(*filename, message);
+ else if (auto command = parser.get_switch("to-shell-script"))
+ ShellManager::instance().eval(*command, context, message, ShellManager::Flags::None, shell_context);
+ else if (parser.get_switch("debug"))
write_to_debug_buffer(message);
else if (parser.get_switch("markup"))
context.print_status(parse_display_line(message, context.faces()));