Add -to-shell-script echo switch
This feature simplifies various small use cases and is a good companion to the existing -to-file switch.
This commit is contained in:
parent
98b84f2b05
commit
ca6a701b80
|
@ -260,6 +260,10 @@ of the file onto the filesystem
|
|||
write the given text to the given file on the host
|
||||
filesystem.
|
||||
|
||||
*-to-shell-script* <script>:::
|
||||
execute the given shell script with the given text
|
||||
written to its standard input
|
||||
|
||||
*-quoting* <quoting>:::
|
||||
define how arguments are quoted in echo output:
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
|
Loading…
Reference in New Issue
Block a user