/
App-Rak.rakudoc
1489 lines (988 loc) · 49.6 KB
/
App-Rak.rakudoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=begin pod
=head1 NAME
App::Rak - 21st century grep / find / ack / ag / rg on steroids
=head1 SYNOPSIS
=begin code :lang<bash>
$ rak foo # look for "foo" in current directory recursively
$ rak foo bar # look for "foo" in directory "bar" recursively
$ rak '/ << foo >> /' # look for "foo" as word in current directory
$ rak foo --files-with-matches # 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
=end code
=head1 DESCRIPTION
App::Rak provides a CLI called C<rak> that allows you to look for a pattern
in (a selection of files) from one or more directories recursively. It has
been modelled after utilities such as C<grep>, C<ack>, C<ag> and C<rg>, with
a little bit of C<find> mixed in, and C<-n> and C<-p> parameters of many
programming languages.
Note: this project is now in beta-development phase. Comments, suggestions
and bug reports continue to be more than welcome!
=head1 POSITIONAL ARGUMENTS
=head2 pattern
The pattern to search for. This can either be a string, or a
L<Raku regular expression|https://docs.raku.org/language/regexes>
(indicated by a string starting and ending with C</>), a
C<Callable> (indicated by a string starting with C<{> and ending with C<}>),
or a a result of L<C<Whatever> currying|https://docs.raku.org/type/Whatever>
(indicated by a string starting with C<*.>).
Can also be specified with the C<--pattern> option, in which case B<all>
the positional arguments are considered to be a path specification.
If the pattern is a C<Callable>, then the dynamic variable C<$*SOURCE> will
contain the C<IO::Path> object of the file being processed. Note that
pattern C<Callable>s will be called in a thread B<unsafe> manner.
=head2 path(s)
Optional. Either indicates the path of the directory (and its
sub-directories), or the file that will be searched. By default, all
directories that do not start with a period, will be recursed into (but
this can be changed with the C<--dir> option).
By default, all files will be searched in the directories. This can be
changed with the C<--file> option.
Paths can also be specified with the C<--paths> option, in which case there
should only be a positional argument for the pattern, or none if C<--pattern>
option was used for the pattern specification.
=head1 ON CALLABLES AS PATTERN
C<Callables> can be specfied by a string starting with C<*.> (so-called
L<Whatever currying|https://docs.raku.org/type/Whatever>, or as a string
starting with C<{> and ending with C<}>.
Note that if a C<Callable> is specified as a pattern, then no highlighting
can be performed as it cannot signal why or where a match occurred.
The return value of the pattern C<Callable> match is interpreted in the
following way:
=head2 True
If the C<Bool>ean True value is returned, assume the pattern is found.
Produce the item unless C<--invert-match> was specified.
=head2 False
If the C<Bool>ean False value is returned, assume the pattern is B<not>
found. Do B<not> produce the item unless C<--invert-match> was specified.
=head2 Nil
If C<Nil> is returned, assume the pattern is B<not> found.
This typically happens when a C<try> is used in a pattern, and an execution
error occurred. Do B<not> produce the item unless C<--invert-match> was
specified.
=head2 Empty
If the empty C<Slip> is returned, assume the pattern is B<not> found.
Do B<not> produce the item unless C<--invert-match> was specified. Shown
in stats as a C<passthru>.
=head2 any other Slip
If a non-empty C<Slip> is returned, produce the values of the C<Slip>
separately for the given item (each with the same item number).
=head3 any other value
Produce that value.
=head1 PHASERS IN CALLABLE PATTERNS
The Raku Programming Language has a number of unique features that can
be used with patterns that are so-called C<Callable>s. One of them is
the use of so-called L<phasers|https://docs.raku.org/language/phasers>
(pieces of code that will be executed automatically when a certain
condition has been met.
C<App::Rak> currently supports all of Raku's
L<loop phasers|https://docs.raku.org/language/phasers#FIRST>:
=item FIRST - code to run when searching starts
=item NEXT - code to run when searching a file is done
=item LAST - code to run when searching is done
These phasers will be called in a thread-safe manner.
=begin code :lang<bash>
$ rak '{ FIRST state $seen = 0; NEXT $seen++; LAST say "$seen files"; .contains("pattern")}'
=end code
Any other phasers that do not require special attention by C<App::Rak>
are also supported in any code specified.
=head1 CREATING YOUR OWN OPTIONS
App::Rak provides B<many> options. If you are happy with a set of options
for a certain workflow, You can use the C<--save> option to save that set
of options and than later access them with the given name:
=begin code :lang<bash>
$ rak --ignorecase --ignoremark --save=im
Saved option '--im' as: --ignorecase --ignoremark
# same as --ignorecase --ignoremark
$ rak foo --im
=end code
You can use the C<--list-custom-options> to see what options you have saved
before.
=head1 SUPPORTED OPTIONS
All options are optional. Any unexpected options, will cause an exception
to be thrown with the unexpected options listed.
=head2 --accessed=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The access time of the file
(number of seconds since epoch, as a C<Num> value) will be passed as the
only argument. Note that many file systems do not actually support this
reliably.
See "CHECKING TIMES ON FILES" for more information about features that
can be used inside the C<Callable>.
=head2 --absolute
Flag. If specified with a trueish value indicates that whenever paths
are shown, they will be shown as absolute paths. Defaults to C<False>,
which will cause paths to be shown as paths relative to the current
directory.
=head2 --after-context=N
Indicate the number of lines that should be shown B<after> any line that
matches. Defaults to B<0>. Will be overridden by a C<--context> argument.
=head2 --allow-loose-escapes
Only applicable if C<--csv-per-line> has been specified. Flag. If specified,
indicates that B<any> character may be escaped.
=head2 --allow-loose-quotes
Only applicable if C<--csv-per-line> has been specified. Flag. If specified,
indicates that fields do not need to be quoted to be acceptable.
=head2 --allow-whitespace
Only applicable if C<--csv-per-line> has been specified. Flag. If specified,
indicates that whitespace is allowed around separators.
=head2 --auto-diag
Only applicable if C<--csv-per-line> has been specified. Flag. If
(implicitly) specified with a trueish value, will show diagnostic information
about problems that occurred during parsing of the CSV file. The default is
C<True>.
=head2 --backup[=extension]
Indicate whether backups should be made of files that are being modified.
If specified without extension, the extension C<.bak> will be used.
=head2 --batch=N
Indicate the number of files that should be checked per thread. Defaults
to C<64> if not specified. See also <--degree>.
=head2 --before-context=N
Indicate the number of lines that should be shown B<before> any line that
matches. Defaults to B<0>. Will be overridden by a C<--context> argument.
=head2 --blame-per-file
Flag. Only makes sense if the pattern is a C<Callable>. If specified with a
C<True> value, indicates that each of the selected files will be provided as
L<C<Git::Blame::File>|https://raku.land/zef:lizmat/Git::Blame::File#methods-on-gitblamefile>
objects if C<git blame> can be performed on the a selected file. If that
is not possible, then the selected file will be ignored.
If <git blame> information can be obtained, then the associated
C<Git::Blame::File> object will be presented to the pattern C<Callable>.
If the Callable returns a true value, then filename will be shown. If the
returned value is a string, then that string will be shown.
=begin code :lang<bash>
# show files with more than 10 commits
$ rak '*.commits > 10' --blame-per-file --files-with-matches
=end code
Requires that the L<C<Git::Blame::File>|https://raku.land/zef:lizmat/Git::Blame::File> module is installed.
=head2 --blame-per-line
Flag. Only makes sense if the pattern is a C<Callable>. If specified with a
C<True> value, indicates that each line from the selected files will be
provided as L<C<Git::Blame::Line>|https://raku.land/zef:lizmat/Git::Blame::File#accessors-on-gitblameline>
objects if C<git blame> can be performed on the a selected file. If that
is not possible, then the selected file will be ignored.
If <git blame> information can be obtained, then the associated
C<Git::Blame::Line> object will be presented to the pattern C<Callable>.
If the Callable returns a true value, then the short representation of
the C<git blame> information will be shown. If the returned value is a
string, then that string will be shown.
=begin code :lang<bash>
# show git blame on lines of which the author is "Scooby Doo"
$ rak '{ .author eq "Scooby Doo" }' --blame-per-line
=end code
Requires that the L<C<Git::Blame::File>|https://raku.land/zef:lizmat/Git::Blame::File> module is installed.
=head2 --blocks=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The number of logical blocks
that a file takes up in the filesystem, will be passed as the only argument.
=begin code :lang<bash>
# show files that consist of at least 3 blocks
$ rak --find --blocks='* >= 3'
=end code
=head2 --break[=string]
Indicate whether there should be a visible division between matches of
different files. Can also be specified as a string to be used as the
divider. Defaults to C<True> (using an empty line as a divider) if
C<--group-matches> is (implicitly) set to C<True>, else defaults to C<False>.
=head2 --checkout=branch
Only valid if the current directory is under git version control. Indicate
the branch to checkout by the general matching logic of App::Rak. Will
produce listing of matching branches if more than one, or say that there
is no match. Branches need not have been checked out locally yet.
=head2 --context=N
Indicate the number of lines that should be shown B<around> any line that
matches. Defaults to B<0>. Overrides any a C<--after-context> or
C<--before-context> arguments.
=head2 --count-only
Flag. Indicate whether just the number of lines with matches should be
calculated. When specified with a C<True> value, will show a "N matches
in M files" by default, and if the C<:files-with-matches> (or
C<files-without matches>) option is also specified with a C<True> value,
will just show total counts. See also C<stats-only>.
=head2 --created=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The creation time of the file
(number of seconds since epoch, as a C<Num> value) will be passed as the
only argument.
See "CHECKING TIMES ON FILES" for more information about features that
can be used inside the C<Callable>.
=head2 --csv-per-line
Flag. Only makes sense if the pattern is a C<Callable>. If specified with a
C<True> value, indicates that selected files should be interpreted as
comma separated values (CSV). Each row from the selected files will be
provided as a list of strings (or of C<CSV::Field> objects).
Attempt to interpret file as a CSV file, and pass each row as a List to
to the pattern Callable. Only files with extensions from the C<#csv> group
will be tried, unless overridden by any explicit extension specification.
More documentation can be found with the
L<Text::CSV|https://raku.land/github:Tux/Text::CSV> module itself.
=head2 --degree=N
Indicate the number of worker threads that should be maximally. Defaults
to the number of cores minus 1 if not specified. See also <--batch>.
=head2 --device-number=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The device number of the
filesystem on which the file is located, will be passed as the only argument.
=head2 --dir=condition
If specified, indicates the C<Callable> that should return True to have a
directory be included for further recursions in file selection. The basename
of the directory will be passed as the only argument. Defaults to all
directories that do not start with a period. Can specify as a flag to
include B<all> directories for recursion.
=head2 --dont-catch
Flag. If specified with a trueish value, will B<not> catch any error
during processing, but will throw any error again. Defaults to C<False>,
making sure that errors B<will> be caught. Mainly intended for debugging
and error reporting.
=head2 --dryrun
Flag. Indicate to B<not> actually make any changes to any content
modification if specified with a C<True> value. Only makes sense together
with the C<--modify-files> and the C<--rename-files> option.
=head2 --edit[=editor]
Indicate whether the patterns found should be fed into an editor for
inspection and/or changes. Defaults to C<False>. Optionally takes the
name of the editor to be used.
=head2 --eol=[lf|cr|crlf]
Only applicable if C<--csv-per-line> has been specified. Indicate a
line ending different from the standard line ending assumed by the system.
Can be specified as C<lf> for a single LineFeed character, C<cr> for a
single CarriageReturn character, or C<crlf> for a combination of a
CarriageReturn and a LineFeed character.
=head2 --escape=["]
Only applicable if C<--csv-per-line> has been specified. Indicates the
escape character to be used to escape characters in a field. Defaults to
B<double quote>.
=head2 --exec=invocation
If specified, indicates the name of a program and its arguments to be
executed. Any C<$_> in the invocation string will be replaced by the file
being checked. The file will be included if the program runs to a successful
conclusion.
=head2 --extensions=spec
Indicate the extensions of the filenames that should be inspected.
By default, no limitation on filename extensions will be done.
Extensions can be specified as a comma-separated list of either a
a predefined group of extensions (indicated by C<#name>), or a single
extension.
=begin code :lang<bash>
# inspect files with extensions used by Raku and Perl
$ rak foo --extensions=#raku,#perl
# inspect files with Markdown content
$ rak foo --extensions=md,markdown
# inspect files without extension
$ rak foo --extensions=
=end code
Predefined groups are C<#raku>, C<#perl>, C<#cro>, C<#text>, C<#c>, C<#c++>,
C<#yaml>, C<#ruby>, C<#python>, C<#html>, C<#markdown>, C<#json>, C<#jsonl>,
C<#csv>, C<#config> and C<#text>.
The C<--list-known-extensions> argument can be used to see which predefined
groups of extensions are supported, and which extensions they cover.
=head2 --file=condition
If specified, indicates the C<Callable> that should return True to have a
file be included in the file selection process. The basename of the file
will be passed as the only argument. Defaults to C<True>, indicating that
all files should be included.
=head2 --file-separator-null
Flag. Indicate to separate filenames by null bytes rather than newlines
if the C<--files-with-matches> option is specified with a C<True> value.
=head2 --files-from=filename
Indicate the path of the file to read filenames from instead of the
expansion of paths from any positional arguments. "-" can be specified
to read filenames from STDIN.
=head2 --files-with-matches
Flag. If specified with a true value, will only produce the filenames of
the files in which the pattern was found. Defaults to C<False>.
=head2 --files-without-matches
Flag. If specified with a true value, will only produce the filenames of
the files in which the pattern was B<not> found. Defaults to C<False>.
=head2 --filesize=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The number of bytes of data
in the file, will be passed as the only argument.
=begin code :lang<bash>
# show files that consist of at 30 bytes
$ rak --find --filesize='* >= 30'
=end code
=head2 --find
Flag. If specified with a true value, will B<not> look at the contents of
the selected paths, but instead consider the selected paths as lines in a
virtual file.
=head2 --find-all
Flag. If specified with a true value, will override any file or directory
filter settings and include all possible files for inspection.
=head2 --only-first[=N]
Indicate the B<overall> number of matches to show. If specified without a
value, will default to B<1>. Defaults to B<1000> if a human is watching,
otherwise defaults to returning all possible matches.
=head2 --formula=[none]
Only applicable if C<--csv-per-line> has been specified. If specified,
indicates the action to be taken when a field starts with an equal sign
(indicating a formula of some kind in many spreadsheets). The following
values are recognized:
=item none - take not action, just pass on
=item die - throw an exception
=item diag - report line and position where formula was found
=item empty - replace the formula by an empty string
=head2 --frequencies
Flag. If specified, will produce a frequency table of the matches with
the most frequent match first. Default is C<False>. See also C<--unique>;
=head2 --gid=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The numeric C<gid> of the file
will be passed as the only argument. Can also be specified as a single
numeric argument. See also C<--group>.
=begin code :lang<bash>
# show files of which the numeric group id is greater than 20
$ rak --find --gid='* > 20'
# show files of which the numeric group id is 20
$ rak --find --gid=20
=end code
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --group=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The name of the group
associated with the C<gid> of the file will be passed as the only argument.
Can also be specified as a list of comma separated names to (not) select on.
To select all names B<except> the listed named, prefix with a C<!>.
See also C<--gid>. Requires the
L<P5getgrnam|https://raku.land/zef:lizmat/P5getgrnam> module to be installed.
=begin code :lang<bash>
# files of which the name associated with the user id starts with underscore
$ rak --find --group='*.starts-with("_")'
# show files of which the group is "staff"
$ rak --find --group=staff
# show files of which the group is NOT "staff"
$ rak --find --group='!staff'
=end code
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --group-matches
Flag. Indicate whether matches of a file should be grouped together by
mentioning the filename only once (instead of on every line). Defaults
to C<True>.
=head2 --hard-links=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The number of hard-links to
the file on the filesystem, will be passed as the only argument.
=head2 --has-setgid
Flag. If specified with a trueish value, will only select files that do have
the SETGID bit set in their attributes. Use negation C<--/has-setgid> to
only select files that do B<not> have the SETGID bit set.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --has-setuid
Flag. If specified with a trueish value, will only select files that do have
the SETUID bit set in their attributes. Use negation C<--/has-setuid> to
only select files that do B<not> have the SETUID bit set.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --help [area-of-interest]
Show argument documentation, possibly extended by giving the area of
interest, which are:
=item pattern
=item string
=item code
=item input
=item haystack
=item filesystem
=item result
=item listing
=item resource
=item special
=item option
=item general
=item philosophy
=item examples
=head2 --highlight
Flag. Indicate whether the pattern should be highlighted in the line in
which it was found. Defaults to C<True> if a human is watching (aka STDOUT
connected to a terminal), or C<--highlight-before> or C<highlight-after>
are explicitely specified, or C<False> otherwise.
=head2 --highlight--after[=string]
Indicate the string that should be used at the end of the pattern found in
a line. Specifying implies C<--highlight>ing implicitely. If C<--highlight>
or C<--highlight-before> are explicitely specified, will default to whatever
is specified with C<--highlight-before>, or to the ANSI code to end B<bold>.
=head2 --highlight--before[=string]
Indicate the string that should be used at the end of the pattern found in
a line. Specifying implies C<--highlight>ing implicitly. If C<highlight>
is explicitely specified with a trueish value, will default to the terminal
code to start B<bold>.
=head2 --human
Flag. Indicate that search results should be presented in a human readable
manner. This means: filenames shown on a separate line, line numbers
shown, and highlighting performed. Defaults to C<True> if C<STDOUT> is
a TTY (aka, someone is actually watching the search results), otherwise
defaults to C<False>.
=head2 --ignorecase
Flag. If specified with a trueish value, indicates that any matching should
be done case insensitively. Default is C<False>.
=head2 --ignoremark
Flag. If specified with a trueish value, indicates that any matching should
be done without consideration of any accents. Default is C<False>.
=head2 --inode=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The inode number of the file
on the filesystem, will be passed as the only argument.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --invert-match
Flag. If specified with a trueish value, will negate the result of any
match if it has a logical meaning:
=item True -> False
=item Nil -> True
=item Empty -> True
=item none of the above -> just that
=head2 --is-empty
Flag. If specified with a trueish value, will only select files that do not
contain any data. Use negation C<--/is-empty> to only select files that B<do>
contain data.
=head2 --is-executable
Flag. If specified with a trueish value, will only select files that can be
executed by the current user. Use negation C<--/is-executable> to only select
files that are B<not> executable by the current user.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-group-executable
Flag. If specified with a trueish value, will only select files that can be
executed by members of the group of the owner. Use negation
C<--/is-group-executable> to only select files that are B<not> executable by
the members of the group of the owner.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-group-readable
Flag. If specified with a trueish value, will only select files that can be
read by members of the group of the owner. Use negation
C<--/is-group-readable> to only select files that are B<not> readable by
the members of the group of the owner.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-group-writable
Flag. If specified with a trueish value, will only select files that can be
written to by members of the group of the owner. Use negation
C<--/is-group-writable> to only select files that are B<not> writable by
the members of the group of the owner.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-owned-by-group
Flag. If specified with a trueish value, will only select files that are
owned by the group of the current user. Use negation
C<--/is-owned-by-group> to only select files that are B<not> owned by
the group of the current user.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-owned-by-user
Flag. If specified with a trueish value, will only select files that are
owned by current user. Use negation C<--/is-owned-by-user> to only select
files that are B<not> owned by the current user.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-owner-executable
Flag. If specified with a trueish value, will only select files that can be
executed by the owner. Use negation C<--/is-owner-executable> to only select
files that are B<not> executable by the owner.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-owner-readable
Flag. If specified with a trueish value, will only select files that can be
read by the owner. Use negation C<--/is-owner-readable> to only select files
that are B<not> readable by the owner.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-owner-writable
Flag. If specified with a trueish value, will only select files that can be
written to by the owner. Use negation C<--/is-owner-writable> to only select
files that are B<not> writable by the owner.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-readable
Flag. If specified with a trueish value, will only select files that can be
read by the the current user. Use negation C<--/is-readable> to only select
files that are B<not> readable by the current user.
=head2 --is-sticky
Flag. If specified with a trueish value, will only select files that do have
the STICKY bit set in their attributes. Use negation C<--/is-sticky> to
only select files that do B<not> have the STICKY bit set.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-symbolic-link
Flag. If specified with a trueish value, will only select files that are
symbolic links. Use negation C<--/is-symbolic-link> to only select files that
are B<not> symbolic links.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-world-executable
Flag. If specified with a trueish value, will only select files that can be
executed by anybody. Use negation C<--/is-group-executable> to only select
files that are B<not> executable by anybody.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-world-readable
Flag. If specified with a trueish value, will only select files that can be
read by anybody. Use negation C<--/is-world-readable> to only select files
that are B<not> readable by anybody.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-world-writable
Flag. If specified with a trueish value, will only select files that can be
written to by anybody. Use negation C<--/is-world-writable> to only select
files that can B<not> be written to by anybody.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --is-writable
Flag. If specified with a trueish value, will only select files that can be
written to by the current user. Use negation C<--/is-writable> to only select
files that can B<not> be written to by the current user.
=head2 --json-per-elem
Flag. Only makes sense if the pattern is a C<Callable>. If specified with
a C<True> value, indicates that each selected file will be interpreted
as JSON, and if valid, will then produce all elements of the outermost
data structure to the pattern for introspection. If the data structure
is a hash, then key/value C<Pair>s will be produced.
If the Callable returns a true value, the element will be shown. If
the returned value is a string, that string will be mentioned. For example
when searching the list of modules in the zef ecosystem (which consists of
an array of hashes):
=begin code :lang<bash>
$ rak '{ $_ with .<auth> }' META.json --json-per-elem
=end code
=head2 --json-per-file
Flag. Only makes sense if the pattern is a C<Callable>. If specified with
a C<True> value, indicates that each selected file will be interpreted
as JSON, and if valid, will then be given to the pattern for introspection.
If the Callable returns a true value, the filename will be shown. If
the returned value is a string, that string will also be mentioned.
For example:
=begin code :lang<bash>
$ rak '{ $_ with .<auth> }' --json-per-file
=end code
=head2 --json-per-line
Flag. Only makes sense if the pattern is a C<Callable>. If specified with
a C<True> value, indicates that each line from the selected files will be
interpreted as JSON, and if valid, will then be given to the pattern for
introspection. If the Callable returns a true value, the filename and
line number will be shown. If the returned value is a string, that
string will also be mentioned. For example:
=begin code :lang<bash>
$ rak '{ $_ with .<auth> }' --json-per-line
=end code
=head2 --keep-meta
Only applicable if C<--csv-per-line> has been specified. Flag. If specified,
indicates that meta-information will be kept for each field, by presenting
each field as a C<CSV::Field|https://github.com/Tux/CSV/blob/master/doc/Text-CSV.md#csvfield>
object rather than as a string. The most important methods that can be called
on a C<CSV::Field> object are:
=item is-quoted - field was quoted
=item is-binary - field contains undecodable data
=item is-utf8 - field contains decodable data beyond ASCII
=item is-formula = field looks like it contains a spreadsheet formula
=head2 --known-extensions
Flag. Indicate that only files with known extensions (occuring in any of
the C<#groups>) should be searched. Defaults to C<True> if a human is
watching (aka STDOUT is connected to a terminal).
=head2 --list-custom-options
=begin code :lang<bash>
$ rak --list-custom-options
fs: --'follow-symlinks'
im: --ignorecase --ignoremark
=end code
Flag. If specified with a true value and as the only option, will list all
additional options previously saved with C<--save>.
=head2 --list-expanded-options
=begin code :lang<bash>
$ rak --im --list-expanded-options
--ignorecase --ignoremark
=end code
Flag. If specified with a true value, will show all actual options being
activated after having been recursively expanded, and then exit.
Intended as a debugging aid if you have many custom options defined.
=head2 --list-known-extensions
=begin code :lang<bash>
$ rak --list-known-extensions
#c: c h hdl
#c++: cpp cxx hpp hxx
#config: ini
#markdown: md markdown
#perl: (none) pl pm t
#python: py
#raku: (none) raku rakumod rakutest rakudoc nqp t pm6 pl6 pod6 t6
#ruby: rb
#text: (none) txt
#yaml: yaml yml
=end code
Flag. If specified with a true value, will show all known extension
groups and the extensions they represent. Intended as an informational
aid.
=head2 --matches-only
Flag. Indicate whether only the matched pattern should be produced, rather
than the line in which the pattern was found. Defaults to C<False>.
Frequently used in conjunction with C<--per-file>. Will show separated by
space if multiple matches are found on the same line.
=head2 --max-matches-per-file[=N]
Indicate the maximum number of matches that should be produced per file.
If specified as a flag, will assume B<1> for its value. By default, will
produce B<all> possible matches in a file.
=head2 ---meta-modified=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The modification time of meta
information of the file (number of seconds since epoch, as a C<Num> value)
will be passed as the only argument.
See "CHECKING TIMES ON FILES" for more information about features that
can be used inside the C<Callable>.
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --mode=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The full numeric mode value
of the file on the filesystem, will be passed as the only argument.
=begin code :lang<bash>
# list files with sticky bit set
$ rak --find --mode='{ $_ +& 0o1000 }'
=end code
NOTE: support of this feature depends on Raku supporting that feature on
the current operating system.
=head2 --modified=condition
If specified, indicates the C<Callable> that should return True to include a
file in the selection of files to be checked. The modification time of the
file (number of seconds since epoch, as a C<Num> value) will be passed as the
only argument.
See "CHECKING TIMES ON FILES" for more information about features that
can be used inside the C<Callable>.
=head2 --modify-files
Flag. Only makes sense if the specified pattern is a C<Callable>.
Indicates whether the output of the pattern should be applied to the file
in which it was found. Defaults to C<False>.
The C<Callable> will be called for each line, giving the line (B<including>
its line ending). It is then up to the C<Callable> to return:
=head3 False
Remove this line from the file. NOTE: this means the exact C<False> value.
=head3 True
Keep this line unchanged the file. NOTE: this means the exact C<True> value.
=head3 Nil
Keep this line unchanged the file. NOTE: this means the exact C<Nil> value.
=head3 Empty
Keep this line unchanged the file. NOTE: this means the exact C<Empty> value.
This is typically returned as the result of a failed condition. For example,
only change the string "foo" into "bar" if the line starts with "#":
=begin code :lang<bash>
$ rak '{ .subst("foo","bar") if .starts-with("#") }' --modify-files
=end code