lizmat / app-rak Goto Github PK
View Code? Open in Web Editor NEW21st century grep / find / ack / ag / rg on steroids
License: Artistic License 2.0
21st century grep / find / ack / ag / rg on steroids
License: Artistic License 2.0
Hi Liz,
Small bug when trying to set a different field separator in CSV file:
rak --csv-per-line --sep=';' '{ .say }' /tmp/file.csv
'--sep' can only be specified as a flag.
Hi.
i use emacs with flycheck and while i was doing a search i kept editing my file. And since i have flycheck enabled it generates a temporary file named "flycheck_XXXXXXXX". Because of this rak failed with the following exception
A worker in a parallel iteration (hyper or race) initiated here:
in sub MAIN at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/1DB59DA63325592C0EB2D7F93BCB6EA641AF8111 (App::Rak) line 1357
in block <unit> at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/resources/732D462F1780FA65BC56EC589341A86285D15050 line 11
in sub MAIN at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/bin/rak line 3
in block <unit> at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/bin/rak line 1
Died at:
Failed to open file /home/demanuel/github/C7-Technical-Test/src/test/sfr/failover/flycheck_test_exposure_manager.py: No such file or directory
in sub MAIN at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/1DB59DA63325592C0EB2D7F93BCB6EA641AF8111 (App::Rak) line 1357
in block <unit> at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/resources/732D462F1780FA65BC56EC589341A86285D15050 line 11
in sub MAIN at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/bin/rak line 3
in block <unit> at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/bin/rak line 1
Unfortunately it's not possible to disable the writing of temp files ( flycheck/flycheck#334 ). Is it possible to avoid this crash?
Hi Liz! As I notified in irc, SparkyCI/Tomty build fails - http://sparrowhub.io:2222/report/923
no rush, HTH
Aleksei
Hi
I am working (slowly) through your examples in the blog part I and have the below error.
Basically this is a docker image with just rakudo installed on ubuntu:latest
https://github.com/p6steve/raku-Dockerfiles/tree/main/basic-ma
Welcome to Rakudo™ v2022.07.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.07.
My search target is ~/rakudo (the target dir for the rakudo build since those are the only files I have in this build) ;-)
I am hoping to install this cool tool everywhere so thus the shakedown...
~p6steve
root@5f31dd2db51a:~# rak --json-per-file '*<name>'
rakudo/tools/build/binary-release/Windows/META6.json
Star::Modules
rakudo/src/nqp-2022.07/nqp-2022.07/package.json
nqp-js-cross-compiling
rakudo/src/nqp-2022.07/nqp-2022.07/nqp-js-on-js/package.json
nqp-js-on-js
rakudo/src/nqp-2022.07/nqp-2022.07/src/vm/js/nqp-runtime/package.json
nqp-runtime
rakudo/src/nqp-2022.07/nqp-2022.07/src/vm/js/nqp-runtime/tables/shiftjis.json
Type Array does not support associative indexing.
in sub stringify at /root/rakudo/share/perl6/site/sources/3A2871EBDC4A0F35E7C904144CBF80147A27AC84 (App::Rak) line 733
in block at /root/rakudo/share/perl6/site/sources/3A2871EBDC4A0F35E7C904144CBF80147A27AC84 (App::Rak) line 846
in block at /root/rakudo/share/perl6/site/sources/3A2871EBDC4A0F35E7C904144CBF80147A27AC84 (App::Rak) line 758
in sub show-results at /root/rakudo/share/perl6/site/sources/3A2871EBDC4A0F35E7C904144CBF80147A27AC84 (App::Rak) line 744
in sub rak-results at /root/rakudo/share/perl6/site/sources/3A2871EBDC4A0F35E7C904144CBF80147A27AC84 (App::Rak) line 626
in sub action-json-per-file at /root/rakudo/share/perl6/site/sources/3A2871EBDC4A0F35E7C904144CBF80147A27AC84 (App::Rak) line 2444
in sub main at /root/rakudo/share/perl6/site/sources/3A2871EBDC4A0F35E7C904144CBF80147A27AC84 (App::Rak) line 412
in block <unit> at /root/rakudo/share/perl6/site/resources/C97545B72F13E645CCCB7F3CC631C73435E74E4C line 3
in sub MAIN at /root/rakudo/share/perl6/site/bin/rak line 3
in block <unit> at /root/rakudo/share/perl6/site/bin/rak line 1
Hi liz,
another small bug with CSV and --unique ,I've applied my own patch to parsed CSV as array of hashes:
rak --csv-per-line '{ .<a> }' /tmp/test.csv -u
The --unique option is not being handled and will be ignored.
If you believe this to be incorrect, please report an issue with
https://github.com/lizmat/App-Rak/issues/new .
../../../../tmp/test.csv
1:1
2:4
3:1
while it's working for JSON:
rak --json-per-line '{ .<ip_str> }' /tmp/a.json -u
101.43.51.104
[melezhik App-Rak]$ zef install App::Rak
===> Searching for: App::Rak
===> Testing: App::Rak:ver<0.0.12>:auth<zef:lizmat>
===> Testing [OK] for App::Rak:ver<0.0.12>:auth<zef:lizmat>
===> Installing: App::Rak:ver<0.0.12>:auth<zef:lizmat>
1 bin/ script [rak] installed to:
/Users/melezhik/.rakubrew/versions/moar-2022.06/share/perl6/site/bin
[melezhik App-Rak]$ rak foo --human
Cannot resolve caller postcircumfix:<{ }>(VMNull, Str:D); none of these signatures matches:
(\SELF, Mu \key)
(\SELF, Mu \key, Mu \ASSIGN)
(\SELF, Mu \key, Mu :$BIND! is raw)
(\SELF, Mu \key, Bool(Any) :$delete!)
(\SELF, Mu \key, Bool(Any) :$delete!, *%other)
(\SELF, Mu \key, Bool(Any) :$exists!)
(\SELF, Mu \key, Bool(Any) :$exists!, *%other)
(\SELF, Mu \key, Bool(Any) :$kv!, *%other)
(\SELF, Mu \key, Bool(Any) :$p!, *%other)
(\SELF, Mu \key, Bool(Any) :$k!, *%other)
(\SELF, Mu \key, Bool(Any) :$v!, *%other)
(\SELF, Iterable \key)
(\SELF, Iterable \keys, Mu \values)
(\SELF, Iterable \key, :$BIND! is raw)
(\SELF, Iterable \key, Bool(Any) :$delete!, *%other)
(\SELF, Iterable \key, Bool(Any) :$exists!, *%other)
(\SELF, Iterable \key, Bool(Any) :$kv!, *%other)
(\SELF, Iterable \key, Bool(Any) :$p!, *%other)
(\SELF, Iterable \key, Bool(Any) :$k!, *%other)
(\SELF, Iterable \key, Bool(Any) :$v!, *%other)
(\SELF, Whatever)
(\SELF, Whatever, Mu \ASSIGN)
(\SELF, Whatever, :$BIND!)
(\SELF, Whatever, Bool(Any) :$delete!, *%other)
(\SELF, Whatever, Bool(Any) :$exists!, *%other)
(\SELF, Whatever, Bool(Any) :$kv!, *%other)
(\SELF, Whatever, Bool(Any) :$p!, *%other)
(\SELF, Whatever, Bool(Any) :$k!, *%other)
(\SELF, Whatever, Bool(Any) :$p!, *%other)
(\SELF, Whatever, Bool(Any) :$v!, *%other)
(\SELF, :$BIND!)
(\SELF, Bool(Any) :$delete!, *%other)
(\SELF, Bool(Any) :$exists!, *%other)
(\SELF, Bool(Any) :$kv!, *%other)
(\SELF, Bool(Any) :$p!, *%other)
(\SELF, Bool(Any) :$k!, *%other)
(\SELF, Bool(Any) :$p!, *%other)
(\SELF, Bool(Any) :$v!, *%other)
(Mu \SELF, *%other)
in block at /Users/melezhik/.rakubrew/versions/moar-2022.06/share/perl6/site/sources/CF0CA45D52CD1D6E64F533B6BF64A8E32E8C331B (App::Rak) line 137
in sub MAIN at /Users/melezhik/.rakubrew/versions/moar-2022.06/share/perl6/site/sources/CF0CA45D52CD1D6E64F533B6BF64A8E32E8C331B (App::Rak) line 134
in block <unit> at /Users/melezhik/.rakubrew/versions/moar-2022.06/share/perl6/site/resources/A7114D6D7B56D6C6E833071EBD41B3EA96754369 line 3
in sub MAIN at /Users/melezhik/.rakubrew/versions/moar-2022.06/share/perl6/site/bin/rak line 3
in block <unit> at /Users/melezhik/.rakubrew/versions/moar-2022.06/share/perl6/site/bin/rak line 1
Suggestion:
$ rak
# OUTPUT
...example use from README
I got a few failures on zef install (see below)
OK with --force-test
This is a clean ubuntu image
docker run -it p6steve/rakudo:basic
Welcome to Rakudo™ v2022.07.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.07.
root@dde8520a4b0a:/# zef install App::Rak
===> Searching for: App::Rak
===> Updating fez mirror: http://360.zef.pm/
===> Updated fez mirror: http://360.zef.pm/
===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Searching for missing dependencies: as-cli-arguments:ver<0.0.7>:authzef:lizmat, CLI::Version:ver<0.0.8>:authzef:lizmat, has-word:ver<0.0.3>:authzef:lizmat, highlighter:ver<0.0.15>:authzef:lizmat, JSON::Fast::Hyper:ver<0.0.3>:authzef:lizmat, META::constants:ver<0.0.3>:authzef:lizmat, rak:ver<0.0.35>:authzef:lizmat, String::Utils:ver<0.0.13>:authzef:lizmat
===> Searching for missing dependencies: Git::Files:ver<0.0.3>:authzef:lizmat, hyperize:ver<0.0.2>:authzef:lizmat, paths:ver<10.0.7>:authzef:lizmat, path-utils:ver<0.0.10>:authzef:lizmat, Trap:ver<0.0.1>:authzef:lizmat
===> Testing: as-cli-arguments:ver<0.0.7>:authzef:lizmat
===> Testing [OK] for as-cli-arguments:ver<0.0.7>:authzef:lizmat
===> Testing: CLI::Version:ver<0.0.8>:authzef:lizmat
===> Testing [OK] for CLI::Version:ver<0.0.8>:authzef:lizmat
===> Testing: has-word:ver<0.0.3>:authzef:lizmat
===> Testing [OK] for has-word:ver<0.0.3>:authzef:lizmat
===> Testing: highlighter:ver<0.0.15>:authzef:lizmat
===> Testing [OK] for highlighter:ver<0.0.15>:authzef:lizmat
===> Testing: JSON::Fast::Hyper:ver<0.0.3>:authzef:lizmat
===> Testing [OK] for JSON::Fast::Hyper:ver<0.0.3>:authzef:lizmat
===> Testing: META::constants:ver<0.0.3>:authzef:lizmat
===> Testing [OK] for META::constants:ver<0.0.3>:authzef:lizmat
===> Testing: path-utils:ver<0.0.10>:authzef:lizmat
[path-utils] # Failed test 'is /root/.zef/store/dd2ba2fc9d21a6b29081c03d405bcb59a663500b.tar.gz/path-utils-0.0.10/t/01-basic.rakutest owned by user'
[path-utils] # at t/01-basic.rakutest line 61
[path-utils] # Failed test 'is /root/.zef/store/dd2ba2fc9d21a6b29081c03d405bcb59a663500b.tar.gz/path-utils-0.0.10/t/01-basic.rakutest owned by user'
[path-utils] # at t/01-basic.rakutest line 62
[path-utils] # Failed test 'is /root/.zef/store/dd2ba2fc9d21a6b29081c03d405bcb59a663500b.tar.gz/path-utils-0.0.10/t/01-basic.rakutest owned by group'
[path-utils] # at t/01-basic.rakutest line 63
[path-utils] # Failed test 'is /root/.zef/store/dd2ba2fc9d21a6b29081c03d405bcb59a663500b.tar.gz/path-utils-0.0.10/t/01-basic.rakutest owned by group'
[path-utils] # at t/01-basic.rakutest line 64
[path-utils] # You failed 4 tests of 57
===> Testing [FAIL]: path-utils:ver<0.0.10>:authzef:lizmat
Aborting due to test failure: path-utils:ver<0.0.10>:authzef:lizmat (use --force-test to override)
I've just discovered this bug when you try to parse multiple CSV files you get the non unique field error:
> cat /tmp/a.csv
a,b,c,d
1,2,3,4
5,6,7,8
> cat /tmp/b.csv
a,b,c,d
5,6,7,8
1,2,3,4
rak --csv-per-line '{.<a>}' /tmp/*.csv
INI - the header contains nun-unique fields: d(2), a(2), c(2), b(2) : error 1013 @ record 1, field 9, position 0
INI - the header contains nun-unique fields: d(2), a(2), c(2), b(2) : error 1013 @ record 1, field 9, position 0
A worker in a parallel iteration (hyper or race) initiated here:
in sub show-results at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 955
in sub rak-results at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 814
in sub action-csv-per-line at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 2567
in sub main at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 428
in block <unit> at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/resources/D62D8FB6A12F7BE3663F861816A73ECF3CF19D30 line 3
in sub MAIN at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/bin/rak line 3
in block <unit> at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/bin/rak line 1
Died at:
INI - the header contains nun-unique fields: d(2), a(2), c(2), b(2)
in sub show-results at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 955
in sub rak-results at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 814
in sub action-csv-per-line at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 2567
in sub main at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/4A5C6464A66ED80C4A7267EB86D113AB750C4323 (App::Rak) line 428
in block <unit> at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/resources/D62D8FB6A12F7BE3663F861816A73ECF3CF19D30 line 3
in sub MAIN at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/bin/rak line 3
in block <unit> at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/bin/rak line 1
My preferred, default use would be my most often find/grep use: searching for a word in a file in a subdirectory:
$ find . -type f -name "*.rakumod" -exec grep -i foo {} \; -print
so I would like to encapsulate that for 'rak' use. Something like:
RAk_DEFAULT_ACTION='make rak act like my find/grep use'
A brief look at the many options of 'rak' makes me unsure if that can be
done, but I have great confidence in your wielding of the power of Raku.
jdv@jdv-lap:$ cd rakudo/rakudo$ rak role
jdv@jdv-lap:
docs/announce/2009-02
56:* Existing parameterized roles are now reused instead of creating new ones.
...
src/core.c/Rakudo/Internals/HyperToIterator.pm6
2:my role X::HyperRace::Died {
src/core.c/Rakudo/Internals/HyperWorkStage.pm6
4:my role Rakudo::Internals::HyperWorkStage {
12:my role Rakudo::Internals::HyperBatcher does Rakudo::Internals::HyperWorkStage {
18:my role Rakudo::Internals::HyperProcessor does Rakudo::Internals::HyperWorkStage {
29:my role Rakudo::Internals::HyperRebatcher does Rakudo::Internals::HyperWorkStage {
39:my role Rakudo::Internals::HyperJoiner does Rakudo::Internals::HyperWorkStage {
src/core.c/Rakudo/Iterator.pm6
20:# Generic role for iterating over a Blob / Buf. You need to
23:our role Blobby does PredictiveIterator {
58:# Generic role for iterating over a Map / Hash. You must
61:our role Mappy does Iterator {
82:# Generic role for iterating over a Map / Hash that has pairs
86:our role Mappy-kv-from-pairs does Iterator {
148:# Generic role for iterating over a >1 dimensional shaped list
156:our role ShapeBranch does Iterator {
246:# Generic role for iterating over a >1 dimensional shaped list
253:# role supplies an optimized .sink-all.
254:our role ShapeLeaf does Iterator {
417:my role AllButLastRole {
1788:# XXX TODO: Make this code DRYer by moving common bits to a role,
1790:# signature complains about immutable ints if done in a role, and
1791:# private methods in roles are slow, so we duplicated stuff here
2414:my role ListIndex {
2525:# An often occurring use of the Mappy role to generate all of the
2542:# An often occurring use of the Mappy role to generate alternating
2550:# An often occurring use of the Mappy role to generate all of the
4212:# ShapeBranchi roles, but without any additional processing.
This type cannot unbox to a native integer: P6opaque, Scalar
in sub want-lines at /home/jdv/rakudo/install/share/perl6/site/sources/15066A5E79B965690BA65EFE60430F617F71BC47 (App::Rak) line 991
in sub rak at /home/jdv/rakudo/install/share/perl6/site/sources/15066A5E79B965690BA65EFE60430F617F71BC47 (App::Rak) line 609
in block at /home/jdv/rakudo/install/share/perl6/site/resources/0FFDA62CBE59FDD572FDAC1C05E0FDEB24029390 line 4
in sub MAIN at /home/jdv/rakudo/install/share/perl6/site/bin/rak line 3
in block at /home/jdv/rakudo/install/share/perl6/site/bin/rak line 1
jdv@jdv-lap:/rakudo$ raku -v/rakudo$
Welcome to Rakudo™ v2022.06-3-gd4e8b671a.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.06.
jdv@jdv-lap:
Hi Liz,
it seems that in the latest version the --unique --count
is not working as one would expect:
rak "/./" file.txt --unique --count-only
=> should give the number of unique pattern but it only gives the count of non unique.
Or am I missing something ?
I think the following README lines "raku" should be replaced with "Raku":
$ raku foo --files-only # look for "foo", only produce filenames
$ raku foo --before=2 --after=2 # also produce 2 lines before and after
$ raku '{.contains("foo") && .contains("bar")}' # lines with foo AND bar
I.e. the lines above should be:
$ rak foo --files-only # look for "foo", only produce filenames
$ rak foo --before=2 --after=2 # also produce 2 lines before and after
$ rak '{.contains("foo") && .contains("bar")}' # lines with foo AND bar
I have just released PDF::Extract due to not being able to find a simple abstraction over pdftotext and pdf2html CLI tools.
Anyway - based on my superficial understanding of rak, there is no option to open and read pdf files as text...?
Would it be of interest for me to write this as a PR and submit back here?
If so, please can you provide a bit of a steer as to how that would integrate with the current rak implmentation:
--pdf=0|1
There's likely a few other, similar things for eg. Office docs (which I am not currently proposing) and maybe a notion of where / how to generally develop a "file suffix preprocessor" might be a good idea... libreoffice --headless --convert-to "txt:Text (encoded):UTF8" mydocument.doc
maybe
Should be easily reproducible. The stack trace I get:
A worker in a parallel iteration (hyper or race) initiated here:
in sub show-results at /Users/vrurg/.rakubrew/versions/moar-2023.06/install/share/perl6/site/sources/0EF12FD1BF22C1537911336CC1F79E719B4D99E4 (App::Rak) line 975
[...snip...]
Died at:
Failed to open file [...]: Permission denied
in sub show-results at /Users/vrurg/.rakubrew/versions/moar-2023.06/install/share/perl6/site/sources/0EF12FD1BF22C1537911336CC1F79E719B4D99E4 (App::Rak) line 975
Hello,
this is a feature request. Often I find myself wanting to scroll through all Raku-related files but currently it seems one would require to look for specific places in files, and this use-case isn't really supported. I don't know how --edit
works exactly but I suppose it shouldn't be too hard to add a cursor right at the beginning.
on c5aeee1 on main, seeing the following test failures on windows:
$ zef test .
===> Testing: App::Rak:ver<0.0.96>:auth<zef:lizmat>
[App::Rak] Use of uninitialized value of type Any in numeric context
[App::Rak] in code at C:\raku\share\perl6\site\sources\917BB35F93E417835CF3E5D3AFB4D749AA5CF677 (path-utils) line 4
[App::Rak] Use of uninitialized value of type Any in numeric context
[App::Rak] in code at C:\raku\share\perl6\site\sources\917BB35F93E417835CF3E5D3AFB4D749AA5CF677 (path-utils) line 5
===> Testing [OK] for App::Rak:ver<0.0.96>:auth<zef:lizmat>
$ raku --version
Welcome to Rakudo™ v2022.04-42-ge9de06b85e.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.04.
$ zef --version
v0.14.2
This morning tried to upgrade Rak. Got
zef install App::Rak --force-install
===> Searching for: App::Rak
===> Searching for missing dependencies: rak:ver<0.0.22>:auth<zef:lizmat>
===> Testing: rak:ver<0.0.22>:auth<zef:lizmat>
===> Testing [OK] for rak:ver<0.0.22>:auth<zef:lizmat>
===> Testing: App::Rak:ver<0.0.95>:auth<zef:lizmat>
===> Testing [OK] for App::Rak:ver<0.0.95>:auth<zef:lizmat>
===> Installing: rak:ver<0.0.22>:auth<zef:lizmat>
===> Installing: App::Rak:ver<0.0.95>:auth<zef:lizmat>
===> Install [FAIL] for App::Rak:ver<0.0.95>:auth<zef:lizmat>: ===SORRY!=== Error while compiling /home/richard/development/home#sources/91DADAD026AEAA980DA4EE2F1755A62256A17D66 (new)
Variable '@options' is not declared. Did you mean '$option'?
at /home/richard/development/home#sources/91DADAD026AEAA980DA4EE2F1755A62256A17D66 (new):189
------> elsif ⏏@options.map(-> $after {
===SORRY!=== Error while compiling /home/richard/development/home#sources/91DADAD026AEAA980DA4EE2F1755A62256A17D66 (new)
Variable '@options' is not declared. Did you mean '$option'?
at /home/richard/development/home#sources/91DADAD026AEAA980DA4EE2F1755A62256A17D66 (new):189
------> elsif ⏏@options.map(-> $after {
Specification of --ack
should cause interpretation of the remaining arguments to "ack" semantics
rak with --modify-files
produces (I think) incorrect reports and does not allow non-destructive potential results.
a) A zipped directory is attached with three files in a directory 'rak-test'
raktest.zip
b) Two files contain 'processed', one contains 'xrocessed', each file has 9 lines
c) The following rak commands and output were obtained
rak '*.subst(/ "processed" /, ":processing")' rak-test/ --modify-files --dryrun
Processed 3 files, 3 files changed, 27 lines changed
*** no changes where made because of --dryrun ***
$ rak '/ "processed" /' rak-test/ --files-with-matches
rak-test/01.rakutest
rak-test/02.rakutest
After running the first stanza, I would have expected the result to be 3 files, 2 files changed, 4 lines changed
Further, I wanted to see what might be changed.
$ rak '*.subst(/ "processed" /, ":processing")' rak-test/ --modify-files --dryrun --files-with-matches
The --files-with-matches option is not being handled and will be ignored.
If you believe this to be incorrect, please report an issue with <snip>
I have had problems with --modify-files
because I have mis-specified the regex and changed too much or too many files with no way of easily determining what is being picked up.
Perhaps the output to --dryrun --verbose
could be each line changed with the original followed by the changed line (coloured differently ?).
Info:
$ rak --version
rak - provided by App::Rak 0.2.20, running Raku 6.d with Rakudo 2024.02.
I'm just doing:
prompt $ rak --help
.....
Option format:
--foo Option "foo" is True
--/foo Option "foo" is False
--no-foo Option "foo" is False
--foo=bar Option "foo" is "bar"
Use of uninitialized value element of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/B83F4237373A0EFC08A9177A5593B0E12D0FDB31 (CLI::Help) line 14
Unknown help category:
prompt $
Another idea here and sorry if It's already possible with rak but what I love about ack if the fact that you can create a custom output with pattern captured by regex.
For example here you can reformat the datetime format from ISO to European :
ack '(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' --ouput='$3/$2/$1 $4:$5:$6' /path/file
Even more cool would be to combine this with --unique and --stats to get in return all unique value of a matched pattern with the number of hits for each different pattern. There is probably a lot of this pre-baked in Rak but haven't figure it out
Can you plan to add a feature to read pattern from file as in -f in grep ?
Another small bug, when you're running rak multiple time with | it creates an unexpected output:
$: echo 116.203.72.198 >> /tmp/t2
$: rak 11 /tmp/t2 | rak 1 19:30:11
Use of uninitialized value $source-for of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in sub move-filesystem-options-to-rak at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/DB5D9DC1DFF0575D3090DE44DB3FFFDE5EC1A225 (App::Rak) line 2135
Use of uninitialized value $source-for of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in sub move-filesystem-options-to-rak at /Users/.rakubrew/versions/moar-2022.07/share/perl6/site/sources/DB5D9DC1DFF0575D3090DE44DB3FFFDE5EC1A225 (App::Rak) line 2135
../../../../../../tmp/t2:1:116.203.72.198
Any idea why it's doing this ?
Basically: collect the unique commit ID's for the search query, and produce that as result with the title. With --verbose
produce the whole commit message
Perhaps it makes sense, but not to me. Not asking to make it False by default, but having a way to change the default via the config file would be useful.
Sorry if I overlooked something in the docs.
it would be nice to get the CSV parsed just like the JSON using a TEXT::CSV:
my @d=csv(in => "/file.csv",headers => "auto",sep_char=> ";");
@d.[1]<field>
jdv@jdv-lap:~/rakudo$ time rak role
...
This type cannot unbox to a native integer: P6opaque, Scalar
in sub want-lines at /home/jdv/rakudo/install/share/perl6/site/sources/15066A5E79B965690BA65EFE60430F617F71BC47 (App::Rak) line 991
in sub rak at /home/jdv/rakudo/install/share/perl6/site/sources/15066A5E79B965690BA65EFE60430F617F71BC47 (App::Rak) line 609
in block at /home/jdv/rakudo/install/share/perl6/site/resources/0FFDA62CBE59FDD572FDAC1C05E0FDEB24029390 line 4
in sub MAIN at /home/jdv/rakudo/install/share/perl6/site/bin/rak line 3
in block at /home/jdv/rakudo/install/share/perl6/site/bin/rak line 1
real 0m2.199s
user 0m3.718s
sys 0m0.329s
jdv@jdv-lap:~/rakudo$
meanwhile
jdv@jdv-lap:~/rakudo$ time rak role > /dev/null
real 0m16.807s
user 0m23.311s
sys 0m1.240s
jdv@jdv-lap:~/rakudo$
Hi!
if i do rak
without any arguments, it will do something equivalent to a cat
call on all the files from the current folder.
IMHO it would be better to throw an error. For example, the rg behaviour:
demanuel@archlinux ~/Downloads> rg
error: The following required arguments were not provided:
<PATTERN>
USAGE:
rg [OPTIONS] PATTERN [PATH ...]
rg [OPTIONS] -e PATTERN ... [PATH ...]
rg [OPTIONS] -f PATTERNFILE ... [PATH ...]
rg [OPTIONS] --files [PATH ...]
rg [OPTIONS] --type-list
command | rg [OPTIONS] PATTERN
rg [OPTIONS] --help
rg [OPTIONS] --version
For more information try --help
demanuel@archlinux ~/Downloads [2]>
I think it would be nice if we have the same kind of behaviour
For me, this hangs:
rak §reading https://dev.to/lizmat/its-time-to-rak-part-1-30ji
But obtaining the file with 'curl' succeeds:
curl https://dev.to/lizmat/its-time-to-rak-part-1-30ji
Hi Liz,
Great tool ! Do you think you can add quickly the support of other type of compressed archive ?
This would be good for --auto-decompress of feature of Rak.
I've opened another dedicated issue on the relevant lib.
Hi Liz,
Another quick fix , when you're using the --pattern-from
with regex you're doing a loop with each one of the pattern rather than compiling a single regex with all pattern with | this creates a huge performance penalty because you checking the same file over and over based on the number of line in the input file.
Based on my test on a large CSV 93 MB it takes 294 secs against a 99 regex pattern file vs 84 sec if you convert this as a regex with |.
Can you fix this ?
On windows, I'm having trouble installing App::Rak because of the pinned dependency on String::Utils:
$ raku --version
Welcome to Rakudo™ v2022.04-42-ge9de06b85e.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.04.
$ sw_vers.bat
C:\dev\Main.wiki>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.19044 N/A Build 19044
$ zef install App::Rak
===> Searching for: App::Rak
Cannot create a Zef::Distribution from non-existent path: C:\Users\wcoleda\AppData\Local\Temp/.zef\00ce33c0aa6224e70d30fb1fcdf29162fb232529.tar.gz\String-Utils-0.0.8/META6.json
===> Searching for missing dependencies: CLI::Help:ver<0.0.4>:auth<zef:lizmat>, String::Utils:ver<0.0.8>:auth<zef:lizmat>, META::constants:ver<0.0.2>:auth<zef:lizmat>
$ zef install 'String::Utils:ver<0.0.8>'
===> Searching for: String::Utils:ver<0.0.8>
Cannot create a Zef::Distribution from non-existent path: C:\Users\wcoleda\AppData\Local\Temp/.zef\00ce33c0aa6224e70d30fb1fcdf29162fb232529.tar.gz\String-Utils-0.0.8/META6.json
$ zef info String::Utils
- Info for: String::Utils
- Identity: String::Utils:ver<0.0.12>:auth<zef:lizmat>
- Recommended By: Zef::Repository::LocalCache
- Installed: Yes
Description: Provide some optimized string functions
License: Artistic-2.0
Source-url: https://github.com/lizmat/String-Utils.git
Provides: 1 modules
Depends: 0 items
I was able to install version 0.0.12 of String::Utils without issue, so if that dependency were updated, I could install App::Rak
I expect this command to find files in the parent directory (at this point, it lists files in the current directory that have names that include ".."):
rak --find ..
I expect this command to give directories in the parent directory (at this point, gives nothing):
rak --find --dir ..
For comparison, this works as expected:
rak --find --dir .
Another small bug:
lsof -Pni | rak node --count-only
Type check failed in binding to parameter '<anon>'; expected IO::Path but got IO::Handle (IO::Handle.new(path ...).
where using it against a file works as expected:
rak --count-only 1 /tmp/test.csv
2 matches in 1 files
Note the starts--with
.
Partial output from $ rak --help
:
Pattern specification:
foo literal string
'/ << bar >> /' Raku regex indicated by being bounded by / /
'{ .ends-with("bar") }' Raku code indicated by being bounded by { }
'*.starts--with("foo")' Raku WhateverCode starting with *.
either as first argument, or as --pattern=foo option
I'm getting the error:
Failed to find dependencies: JSON::Fast:ver<0.19>:auth<cpan:TIMOTIMO>
when trying:
zef upgrade App::Rak
Doing:
zef search JSON::Fast
Doesn't show a version 0.19 of JSON::Fast
rak --version
rak - provided by App::Rak 0.2.17, running Raku 6.d with Rakudo 2022.12
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? 🤔
Hey,
I've been trying our rak as a replacement for rg etc. and putting it through its paces.
On some folders I have lying around, it is working fast enough for small needles, but when the needle is large it takes too long.
Large needle.
❯ time rak '/ abcdefghijklmnop /'
^C
________________________________________________________
Executed in 69.19 secs fish external
usr time 71.08 secs 126.00 micros 71.08 secs
sys time 0.50 secs 749.00 micros 0.50 secs
Small needle.
❯ time rak '/ a /'
________________________________________________________
Executed in 1.53 secs fish external
usr time 3.32 secs 110.00 micros 3.32 secs
sys time 0.23 secs 685.00 micros 0.23 secs
And an unfair comparision with rg just for kicks.
❯ time rg abcdefghijklmnop
________________________________________________________
Executed in 24.45 millis fish external
usr time 22.26 millis 93.00 micros 22.17 millis
sys time 33.71 millis 618.00 micros 33.09 millis
Unfortunately, I cannot share the data it was being run on. Will try and see if I can replicate it with other data.
I could spend some more time checking this after digging through the code. At this point, I'm not sure if this is an issue with rak or the Raku regex engine. I'd imagine for a simple string the regex engine should go into the usual string search algos. Not sure why it is taking so long.
This would be basically a shortcut to --per-line=.split("\n\n")
, but then reporting the original line number of the paragraph start, rather then the ordinal number of the paragraph.
Reason: for regexes that could potentially span multiple lines, but not span across paragraphs. And having the line number would allow it to work with --edit-files
Hi! I am not sure if this is a Rak or Rakudo or SparkyCI + Docker issue, my feeling is that it all started from #5 , anyway now when SparkyCI logs improved (imho) , it's easier to make a sense of it. Let's consider a simple example of creating file containing foo
and doing a search with rak foo
in cwd:
[rak-count-only]
[repository] - index updated from http://sparrowhub.io/repo//api/v1/index
[task run: task.bash - .tomty/tasks/rak-count-only]
[dump code: task.bash]
[1] set -e
[2]
[3] cd $cache_dir
[4]
[5] rak --version
[6]
[7] echo foo > file.txt
[8] echo foo > file2.txt
[9] echo foo >> file2.txt
[10] echo foo > file3.txt
[11]
[12] rak foo --count-only
[13]
[14] rak foo --files-with-matches --count-only
[15]
[16]
[task stdout]
rak - provided by App::Rak 0.0.98, running Raku 6.d with Rakudo 2022.07.
No files with matches
No files with matches
[task check]
stdout match (s) <4 matches in 3 files> False
stdout match (s) <3 files with matches> False
=================
TASK CHECK FAIL
So for some reasons rak just says "No files with matches", even though file is here, interesting? What makes thing more harder that the issue is only reproduced by on SparkyCI - see full log as en example - https://ci.sparrowhub.io/report/1224 , most of failure (excluding git related) are due to rak just does not see files in cwd, or it looks up at different location . I have not digged into rak code yet, but like a guess, maybe it something where rak relies on some ENV vars, which values are not guaranteed for some (docker based) none standard environments ?
Just a guess. And HTH
Alexey
Would it be better to not call meh()
from inside rak()
? meh()
calls exit
and that wouldn’t make it possible to a user using rak()
on its own module or code to handle that. Could it be an exception?
Hi Liz,
This is probably hopelessly obsolete, but submitting it just in case. On Windows 11 ARM, Rakudo v2022.07, old-ish App::Rak
[C:]rak --find vcvars*
A worker in a parallel iteration (hyper or race) initiated here:
in block at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 978
in sub show-results at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 970
in sub rak-results at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 829
in sub action-per-line at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 3183
in sub main at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 432
in block at C:\tools\Rakudo\share\perl6\site\resources\68C3C68C25FF8BA58EEA3E076E7727305545D824 line 3
in sub MAIN at C:\tools\Rakudo\share\perl6\site\bin\rak line 3
in block at C:\tools\Rakudo\share\perl6\site\bin\rak line 1
Died at:
read from dirhandle failed: 5
in block at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 978
in sub show-results at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 970
in sub rak-results at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 829
in sub action-per-line at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 3183
in sub main at C:\tools\Rakudo\share\perl6\site\sources\87C318009D8A3D88D89D6A020D2EA3393C39565D (App::Rak) line 432
in block at C:\tools\Rakudo\share\perl6\site\resources\68C3C68C25FF8BA58EEA3E076E7727305545D824 line 3
in sub MAIN at C:\tools\Rakudo\share\perl6\site\bin\rak line 3
in block at C:\tools\Rakudo\share\perl6\site\bin\rak line 1
Only submitting in case it is useful to you.
All the best,
Sol
Hello,
I came across this issue while combining rak
with my own text processing. Thanks to the talkative traces, I found the problem: the $only-first
variable stays undefined when the "human" option is on False (either due to --no-human or no tty attached), however, find still relies on that, instead of $stop-after
which is used everywhere else.
I think it's really only that; perhaps I can make a PR for it soon but it irked me enough to note it right now. :P
I'm frequently searching CSV files with 20-30 columns, and when there's a hit it can be hard to know what the columns are. An option to print the first line of a file (either always, or only if that file had a match to the pattern) in addition to any hits would be nice.
I have lots of files with .css
and .scss
.
rak '.table' lib/plugins
==> no resultrak '.table' lib/plugins --extensions=css scss
==> lots of filesSuggestions
#css
with 'css', 'scss', 'sass' (maybe others with css, eg less)Hi Liz,
Another small bug, it seems that Rak is not using the highlighting when you use a file containing regex pattern:
rak --ignore-case --type=regex --patterns-from-file=/path/regex.txt /path/to_search
can you have a look ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.