Skip to content

Commit bdf76bd

Browse files
committed
0.0.16
1 parent 323dcc0 commit bdf76bd

File tree

5 files changed

+102
-15
lines changed

5 files changed

+102
-15
lines changed

Changes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ Revision history for App-Rak
22

33
{{$NEXT}}
44

5+
0.0.16 2022-07-19T17:15:09+02:00
6+
- Bump dependency on "highlighter" to get ":type<ends-with> support
7+
- Bump dependency on "Files::Containing" to get ":type" support
8+
- Add support for --type functionality
9+
- Initial version of --help documentation
10+
511
0.0.15 2022-07-19T12:03:57+02:00
612
- Add support for -I functionality
713
- Add support for -M functionality

META6.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"CLI::Help:ver<0.0.2>:auth<zef:lizmat>",
1010
"CLI::Version:ver<0.0.3>:auth<zef:lizmat>",
1111
"META::constants:ver<0.0.2>:auth<zef:lizmat>",
12-
"highlighter:ver<0.0.11>:auth<zef:lizmat>",
13-
"Files::Containing:ver<0.0.11>:auth<zef:lizmat>",
12+
"highlighter:ver<0.0.12>:auth<zef:lizmat>",
13+
"Files::Containing:ver<0.0.12>:auth<zef:lizmat>",
1414
"as-cli-arguments:ver<0.0.3>:auth<zef:lizmat>",
1515
"Edit::Files:ver<0.0.4>:auth<zef:lizmat>",
1616
"JSON::Fast:ver<0.17>:auth<cpan:TIMOTIMO>"
@@ -35,5 +35,5 @@
3535
],
3636
"test-depends": [
3737
],
38-
"version": "0.0.15"
38+
"version": "0.0.16"
3939
}

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ POSITIONAL ARGUMENTS
3535
pattern
3636
-------
3737

38-
The pattern to search for. This can either be a string, or a regular expression (indicated by a string starting and ending with **/**), or a Callable (indicated by a string starting with **{** and ending with **}**.
38+
The pattern to search for. This can either be a string, or a [Raku regular expression](https://docs.raku.org/language/regexes) (indicated by a string starting and ending with `/`), a `Callable` (indicated by a string starting with `{` and ending with `}`), or a a result of [`Whatever` currying](https://docs.raku.org/type/Whatever) (indicated by a string starting with `*.`).
3939

4040
Can also be specified with the `--pattern` option, in which case **all** the positional arguments are considered to be a path specification.
4141

@@ -194,6 +194,10 @@ To remove a saved set of named arguments, use `--save` as the only named argumen
194194

195195
Indicate the maximum size a line may have before it will be summarized. Defaults to `160` if `STDOUT` is a TTY (aka, someone is actually watching the search results), otherwise defaults to `Inf` effectively (indicating no summarization will ever occur).
196196

197+
* --type[=words|starts-with|ends-with|contains]
198+
199+
Only makes sense if the pattern is a string. With `words` specified, will look for pattern as a word in a line, with `starts-with` will look for the pattern at the beginning of a line, with `ends-with` will look for the pattern at the end of a line, with `contains` will look for the pattern at any position in a line.
200+
197201
--follow-symlinks
198202
-----------------
199203

lib/App/Rak.rakumod

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The modules that we need here, with their full identities
2-
use highlighter:ver<0.0.11>:auth<zef:lizmat>;
3-
use Files::Containing:ver<0.0.11>:auth<zef:lizmat>;
2+
use highlighter:ver<0.0.12>:auth<zef:lizmat>;
3+
use Files::Containing:ver<0.0.12>:auth<zef:lizmat>;
44
use as-cli-arguments:ver<0.0.3>:auth<zef:lizmat>;
55
use Edit::Files:ver<0.0.4>:auth<zef:lizmat>;
66
use JSON::Fast:ver<0.17>:auth<cpan:TIMOTIMO>;
@@ -110,7 +110,11 @@ my sub HELP($text, @keys, :$verbose) {
110110
say "Specific help about '@keys[]':";
111111
say "";
112112
}
113-
say $text;
113+
say $isa-tty
114+
?? $text.lines.map({
115+
!.starts-with(" ") && .ends-with(":") ?? BON ~ $_ ~ BOFF !! $_
116+
}).join("\n")
117+
!! $text;
114118

115119
if $verbose {
116120
say "";
@@ -232,7 +236,9 @@ my sub go-edit-files($editor, $needle, @paths, %_ --> Nil) {
232236

233237
my $files-only := %_<files-with-matches>:delete;
234238
my %ignore := named-args %_, :ignorecase :ignoremark;
235-
my %additional = |(named-args %_, :batch, :degree, :max-count), |%ignore;
239+
my %additional =
240+
|(named-args %_, :max-count, :type, :batch, :degree),
241+
|%ignore;
236242
meh-if-unexpected(%_);
237243

238244
edit-files ($files-only
@@ -253,7 +259,7 @@ my sub replace-files($needle, @paths, %_ --> Nil) {
253259
my sub count-only($needle, @paths, %_ --> Nil) {
254260
my $files-with-matches := %_<files-with-matches>:delete;
255261
my %additional := named-args %_,
256-
:ignorecase, :ignoremark, :invert-match, :batch, :degree;
262+
:ignorecase, :ignoremark, :invert-match, :type, :batch, :degree;
257263
meh-if-unexpected(%_);
258264

259265
my int $files;
@@ -268,7 +274,7 @@ my sub count-only($needle, @paths, %_ --> Nil) {
268274

269275
my sub files-only($needle, @paths, %_ --> Nil) {
270276
my %additional := named-args %_,
271-
:ignorecase, :ignoremark, :invert-match, :batch, :degree;
277+
:ignorecase, :ignoremark, :invert-match, :type, :batch, :degree;
272278
meh-if-unexpected(%_);
273279

274280
say .relative
@@ -280,7 +286,7 @@ my sub want-lines($needle, @paths, %_ --> Nil) {
280286
my $ignoremark := %_<ignoremark>:delete;
281287
my $seq := files-containing
282288
$needle, @paths, :$ignorecase, :$ignoremark, :offset(1),
283-
|named-args %_, :invert-match, :max-count, :batch, :degree,
289+
|named-args %_, :invert-match, :max-count, :type, :batch, :degree,
284290
;
285291

286292
my UInt() $before = $_ with %_<before-context>:delete;
@@ -416,9 +422,12 @@ suggestions are more than welcome!
416422
417423
=head2 pattern
418424
419-
The pattern to search for. This can either be a string, or a regular
420-
expression (indicated by a string starting and ending with B</>), or a
421-
Callable (indicated by a string starting with B<{> and ending with B<}>.
425+
The pattern to search for. This can either be a string, or a
426+
L<Raku regular expression|https://docs.raku.org/language/regexes>
427+
(indicated by a string starting and ending with C</>), a
428+
C<Callable> (indicated by a string starting with C<{> and ending with C<}>),
429+
or a a result of L<C<Whatever> currying|https://docs.raku.org/type/Whatever>
430+
(indicated by a string starting with C<*.>).
422431
423432
Can also be specified with the C<--pattern> option, in which case B<all>
424433
the positional arguments are considered to be a path specification.
@@ -614,6 +623,14 @@ Defaults to C<160> if C<STDOUT> is a TTY (aka, someone is actually watching
614623
the search results), otherwise defaults to C<Inf> effectively (indicating
615624
no summarization will ever occur).
616625
626+
=item --type[=words|starts-with|ends-with|contains]
627+
628+
Only makes sense if the pattern is a string. With C<words> specified,
629+
will look for pattern as a word in a line, with C<starts-with> will
630+
look for the pattern at the beginning of a line, with C<ends-with>
631+
will look for the pattern at the end of a line, with C<contains> will
632+
look for the pattern at any position in a line.
633+
617634
=head2 --follow-symlinks
618635
619636
Indicate whether symbolic links to directories should be followed. Defaults

resources/help.txt

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
See https://raku.land/zef:lizmat/App::Rak for now.
1+
Pattern specification:
2+
foo string
3+
'/ << bar >> /' Raku regex indicated by being bounded by / /
4+
'{ .ends-with("bar") }' Raku code indicated by being bounded by { }
5+
'*.starts--with("foo")' Raku WhateverCode starting with *.
6+
either as first argument, or as --pattern=foo option
7+
8+
String search pattern modifiers:
9+
--ignorecase Ignore distinction between upper, lower and title case letters
10+
--ignoremark Only compare base characters, ignore additional marks
11+
--type=words Look for string as a word
12+
--type=starts-with Look for string at start of a line
13+
--type=ends-with Look for string at end of a line
14+
--type=contains Look for string anywhere (default)
15+
16+
Code pattern helpers:
17+
--I=lib First look for any modules to load in the "lib" directory
18+
--M=foo Load module "foo" before compiling Raku code pattern
19+
20+
Haystack specification:
21+
all other arguments (default: current directory)
22+
--follow-symlinks Whether to follow symlinked directories (default: don't)
23+
24+
Result modifiers:
25+
--only-matching Only produce the actual matches
26+
--summary-if-larger-than=N Summarize matching line if longer than N chars
27+
--trim Remove whitespace, true if no context
28+
--highlight Highlight matches if possible
29+
--highlight-before=xxx String to put before match
30+
--highlight-after=yyy String to put after match
31+
--count-only Only return count of matches
32+
--files-with-matches Only return filenames with matches
33+
34+
Listing modifiers:
35+
--before-context=N List N lines before any line with a match
36+
--after-context=N List N lines after any line with a match
37+
--context=N List N lines around any line with a match
38+
39+
Resource usage:
40+
--batch=N max number of files to process in a thread (default: 64)
41+
--degree=N max number of threads to use for processing (default: cores - 1)
42+
43+
Edit options:
44+
--edit[=editor] Go edit the result in an editor, (default EDITOR or vim)
45+
46+
Option management:
47+
--save=name Translate --name to all other options specified,
48+
remove if --save was the only option specified
49+
--list-additional-options List all previously saved options
50+
51+
General options:
52+
--help Show this
53+
--help foo Show additional help about: pattern | string | code | haystack |
54+
result | listing | resource | edit | option | general
55+
--version Show version information
56+
--verbose Be more verbose, if applicable
57+
58+
Option format:
59+
--foo Option "foo" is True
60+
--/foo Option "foo" is False
61+
--foo=bar Option "foo" is "bar"

0 commit comments

Comments
 (0)