Skip to content

Commit

Permalink
Quite some work and fixes
Browse files Browse the repository at this point in the history
- add support for --patterns-from
- add support for --type=auto|regex|code
- various fixes
  • Loading branch information
lizmat committed Oct 27, 2022
1 parent c26e474 commit e9ae633
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 49 deletions.
9 changes: 7 additions & 2 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
Revision history for App-Rak

{{$NEXT}}
- Fixed a (implicit) --smartcase blocking use of --unicode
- Bumped dependency on highlighter to get multiple needle support
- Fix issue with handling unknown extension groups, Mustafa Aydın++
- Add support for --patterns-from
- Add support for --type=auto|regex|code

0.1.12 2022-10-22T13:04:37+02:00
- Add dependency on IO::Path::AutoDecompress to make --auto-decompress
option an option that is always available
- Bump dependency on String::Utils to get "non-word"
- Make regexes that consist of a literal string of word characters
only, use the much faster .contains logic rather than going the
full regex way.
only, use the much faster .contains logic on the literal string,
rather than going the full regex way

0.1.11 2022-10-20T16:01:39+02:00
- Add support for --auto-decompress
Expand Down
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"as-cli-arguments:ver<0.0.7>:auth<zef:lizmat>",
"CLI::Version:ver<0.0.8>:auth<zef:lizmat>",
"has-word:ver<0.0.3>:auth<zef:lizmat>",
"highlighter:ver<0.0.15>:auth<zef:lizmat>",
"highlighter:ver<0.0.16>:auth<zef:lizmat>",
"IO::Path::AutoDecompress:ver<0.0.2>:auth<zef:lizmat>",
"JSON::Fast::Hyper:ver<0.0.3>:auth<zef:lizmat>",
"META::constants:ver<0.0.3>:auth<zef:lizmat>",
Expand Down
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1330,9 +1330,56 @@ Flag. Only applicable if `--csv-per-line` has been specified. If specified, then

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).

* --type=words|starts-with|ends-with|contains
--type=string
-------------

The `--type` argument indicates how any pattern, as specified on the commmand line, or from previously saved options, should be interpreted. If not specified specified, will assume `auto`.

The following strings can be specified:

### auto

If `--type=auto` is (implicitely) specified, will look for cues in a specified pattern to understand what functionality is requested. The following cues are currently supported:

* / regex /

A string starting and ending with a slash `/`, will be interpreted as a Raku regex. This will honour any `--smartcase`, `--ignorecase` and `--ignoremark` specifications.

* { code }

A string starting with a curly brace open `{` and ending with a curly brace close `}`, will be interpreted as Raku source code to be compiled.

* *code

A string starting with an asterisk `*` will be interpreted as Raku source code, assuming Whatever currying semantics.

* literal

Otherwise, the string will be interpreted as a literal string to search for, with `--type=contains` semantics. This will honour any `--smartcase`, `--ignorecase` and `--ignoremark` specifications.

### regex

If `type=regex` is specified, then a pattern will be interpreted as a regex, as if it was surrounded by slashes.

### code

If `type=code` is specified, then a pattern will be interpreted as Raku source code, as if it was surrounded by curly braces.

### contains

If `type=contains` is specified, then a pattern will be interpreted as a literal string, while honouring any `--smartcase`, `--ignorecase` and `--ignoremark` specifications.

### words

If `type=words` is specified, then a pattern will be interpreted as a literal string that should be bounded by word boundares at both ends, while honouring any `--smartcase`, `--ignorecase` and `--ignoremark` specifications.

### starts-with

If `type=starts-with` is specified, then a pattern will be interpreted as a literal string that should occur at the **start** of a line, while honouring any `--smartcase`, `--ignorecase` and `--ignoremark` specifications.

### ends-with

Only makes sense if the pattern is a literal 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 (which is the default).
If `type=ends-with` is specified, then a pattern will be interpreted as a literal string that should occur at the **end** of a line, while honouring any `--smartcase`, `--ignorecase` and `--ignoremark` specifications.

--trim
------
Expand Down
77 changes: 70 additions & 7 deletions doc/App-Rak.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ Only applicable if C<--csv-per-line> has been specified. Flag. If
(implicitly) specified, will show diagnostic information about problems
that occurred during parsing of the CSV file. The default is C<True>.

=head2 backtrace
=head2 --backtrace

Flag. When specified with a True value, will interpret either standard
input, or a single file, as a Raku backtrace. And produce a result
Expand Down Expand Up @@ -1652,13 +1652,76 @@ Defaults to C<160> if C<STDOUT> is a TTY (aka, someone is actually watching
the search results), otherwise defaults to C<Inf> effectively (indicating
no summarization will ever occur).

=item --type=words|starts-with|ends-with|contains
=head2 --type=string

Only makes sense if the pattern is a literal string. With C<words> specified,
will look for pattern as a word in a line, with C<starts-with> will
look for the pattern at the beginning of a line, with C<ends-with>
will look for the pattern at the end of a line, with C<contains> will
look for the pattern at any position in a line (which is the default).
The C<--type> argument indicates how any pattern, as specified on the
commmand line, or from previously saved options, should be interpreted.
If not specified specified, will assume C<auto>.

The following strings can be specified:

=head3 auto

If C<--type=auto> is (implicitely) specified, will look for cues in a
specified pattern to understand what functionality is requested. The
following cues are currently supported:

=item / regex /

A string starting and ending with a slash C</>, will be interpreted as a
Raku regex. This will honour any C<--smartcase>, C<--ignorecase> and
C<--ignoremark> specifications.

=item { code }

A string starting with a curly brace open C<{> and ending with a curly
brace close C<}>, will be interpreted as Raku source code to be compiled.

=item *code

A string starting with an asterisk C<*> will be interpreted as Raku source
code, assuming Whatever currying semantics.

=item literal

Otherwise, the string will be interpreted as a literal string to search for,
with C<--type=contains> semantics. This will honour any C<--smartcase>,
C<--ignorecase> and C<--ignoremark> specifications.

=head3 regex

If C<type=regex> is specified, then a pattern will be interpreted as a
regex, as if it was surrounded by slashes.

=head3 code

If C<type=code> is specified, then a pattern will be interpreted as Raku
source code, as if it was surrounded by curly braces.

=head3 contains

If C<type=contains> is specified, then a pattern will be interpreted as a
literal string, while honouring any C<--smartcase>, C<--ignorecase> and
C<--ignoremark> specifications.

=head3 words

If C<type=words> is specified, then a pattern will be interpreted as a
literal string that should be bounded by word boundares at both ends,
while honouring any C<--smartcase>, C<--ignorecase> and C<--ignoremark>
specifications.

=head3 starts-with

If C<type=starts-with> is specified, then a pattern will be interpreted as
a literal string that should occur at the B<start> of a line, while honouring
any C<--smartcase>, C<--ignorecase> and C<--ignoremark> specifications.

=head3 ends-with

If C<type=ends-with> is specified, then a pattern will be interpreted as
a literal string that should occur at the B<end> of a line, while honouring
any C<--smartcase>, C<--ignorecase> and C<--ignoremark> specifications.

=head2 --trim

Expand Down
Loading

0 comments on commit e9ae633

Please sign in to comment.