Closed Canop closed 1 week ago
These are the verbs I tested against
{
invocation: "echo_stdout_quit"
external: "echo {file}"
from_shell: true
}
{
invocation: "test_stdout_quit"
cmd: ":write_stdout {file};:quit"
}
{
invocation: "testln_stdout_quit"
cmd: ":writeln_stdout {file};:quit"
}
{
invocation: "test_stdout"
cmd: ":write_stdout {file}"
}
{
invocation: "testln_stdout"
cmd: ":writeln_stdout {file}"
}
I'm seeing a few oddities here.
In no particular order:
write_stdout
and writeln_stdout
be callable from within broot? They don't accomplish much outside of verb use.echo {file}
from shell.
test*
verbs don't trigger the above error, but they also simply aren't found if more than one file is staged.
testln_stdout
it is possible to accumulate files on stdout. Unfortunately this smacks us right into the original problem from #888 : there's a newline at the end of the list. Note: I reverted my changes in br.ps1 to test this PR.
test_stdout_quit
it is possible to pass one file to powershell.
But of course, multiple invocations of test_stdout
won't help with further files.
I do see a workaround - calling testln_stdout
for some files, and test_stdout_quit
on the last file. I don't know that this qualifies as a solution though.
test<tab>
, but testln<tab>
autocompletes to testln_stdout_quit
and will not cycle with the other match testln_stdout
. 🤷 In summary, write_stdout
and writeln_stdout
narrowly avoid solving the problem :)
write_stdout
only supports passing one filewriteln_stdout
always contains a problematic newlineAs a final thought - in addition to text output, it might be worth supporting json output, too. That's a trendy thing to do these days, and would play quite nicely with object oriented shells like powershell. Or any shell could leverage something like jq
.
A lot of good point. Also https://github.com/Canop/broot/issues/888#issuecomment-2224324287
An approach might be to allow more settings to be carried by verb arguments, using the syntax I introduced at https://github.com/Canop/broot/blob/main/CHANGELOG.md#v091---2019-07-29
This could for example be write_stdout {file:comma-separated};:quit
or write_stdout {directory:json-array}
or write_stdout {directory:lines}
.
I'll be cautious though, as I don't want to be carried into introducing user-side complexity solving only one problem.
I'm dropping this PR and will try another approach.
The
:writeln_stdout
internal allows recreating the:print_path
verb:but it's more generic.
With the
:write_stdout
, you can for example write the path without the trailing newline: