lizmat / App-Rak

21st century grep / find / ack / ag / rg on steroids
Artistic License 2.0
152 stars 7 forks source link

new version of cli app does not write line numbers and header when an output is redirected #2

Closed melezhik closed 2 years ago

melezhik commented 2 years ago

Hi!

Old version:

[melezhik App-Rak]$ tomty rak-search
[rak-search] ....... 
18:07:27 07/11/2022 [repository] :: index updated from http://sparrowhub.io/repo/api/v1/index
18:07:27 07/11/2022 [.tomty/tasks/rak-search/] :: <<<
18:07:27 07/11/2022 [.tomty/tasks/rak-search/] :: execute: rak foo
18:07:27 07/11/2022 [.tomty/tasks/rak-search/] :: file.txt
18:07:27 07/11/2022 [.tomty/tasks/rak-search/] ::  1:foo
18:07:27 07/11/2022 [.tomty/tasks/rak-search/] :: >>>
[task check] stdout match (s) <<<<> True
[task check] stdout match (s) <execute: rak foo> True
[task check] stdout match (s) <file.txt> True
[task check] stdout match (s) <^^ \s+ '1:foo' \s* $$> True
[task check] stdout match (s) <>>>> True

New version:

[melezhik App-Rak]$ tomty rak-search
11:10:31 07/15/2022 [repository] :: index updated from http://sparrowhub.io/repo/api/v1/index
11:10:31 07/15/2022 [.tomty/tasks/rak-search/] :: <<<
11:10:31 07/15/2022 [.tomty/tasks/rak-search/] :: execute: rak foo
11:10:31 07/15/2022 [.tomty/tasks/rak-search/] :: foo
11:10:31 07/15/2022 [.tomty/tasks/rak-search/] :: >>>
[task check] stdout match (s) <<<<> True
[task check] stdout match (s) <execute: rak foo> True
[task check] stdout match (s) <file.txt> False
[task check] stdout match (s) <^^ \s+ '1:foo' \s* $$> False
[task check] stdout match (s) <>>>> False
=================
TASK CHECK FAIL

It boils down to the fact that rak no longer prints line numbers and header in case an output is redirected:

[melezhik App-Rak]$ rak foo100 
foo.txt
 1: foo100
[melezhik App-Rak]$ rak foo100 | cat 
foo100
[melezhik App-Rak]$ 

But maybe this is intentionally? 🤔

melezhik commented 2 years ago

oh , looks like defaults have been changed ...

melezhik commented 2 years ago

adjusted my Tommy tests

melezhik commented 2 years ago
[melezhik App-Rak]$ tomty --all 
[1/4] / [rak-search] .......  1 sec. OK
[2/4] / [rak-search-before-after] .......  4 sec. OK
[3/4] / [rak-search-dir] .......  1 sec. OK
[4/4] / [rak-search-files-only] .......  1 sec. OK
lizmat commented 2 years ago

Yeah, when redirecting to a file, typically line numbers are not written out by default.

These things are not completely set in stone yet. Especially since I've only today became aware of ag

melezhik commented 2 years ago

no worries. I like the idea Raku would have it's equivalent of all this search tools. I have taken care of redirecting feature in my Tomty tests already, waiting for your feedback on my PR ... ))