Skip to content

Commit

Permalink
0.3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Aug 20, 2024
1 parent b46b9fd commit 0b34264
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Revision history for App-Rak

{{$NEXT}}

0.3.12 2024-08-20T16:21:00+02:00
- Make --modify-files present the target without line endings
by default. Specify --with-line-endings if you want them
included

0.3.11 2024-08-19T21:37:28+02:00
- Bump "rak" to get ParaSeq's exception handling fix

Expand Down
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
],
"test-depends": [
],
"version": "0.3.11"
"version": "0.3.12"
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,9 @@ See "CHECKING TIMES ON FILES" for more information about features that can be us

Flag. Only makes sense if the specified pattern is a `Callable`. Indicates whether the output of the pattern should be applied to the file in which it was found. Defaults to `False`.

The `Callable` will be called for each file (in sorted order) and each line of the file, giving the line (**including** its line ending). The `$*N` dynamic variable is available inside the `Callable` and is initialized to 0 (in case modifications require keeping numeric state between calls). It is then up to the `Callable` to return:
The `Callable` will be called for each file (in sorted order) and each line of the file, giving the line. By default, the line will be presented to the code **without** its line ending. You need to specify `--with-line-endings` if you want to have the line ending also.

The `$*N` dynamic variable is available inside the `Callable` and is initialized to 0 (in case modifications require keeping numeric state between calls). It is then up to the `Callable` to return:

### False

Expand Down
7 changes: 5 additions & 2 deletions doc/App-Rak.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -1576,8 +1576,11 @@ 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 file (in sorted order) and each
line of the file, giving the line (B<including> its line ending). The
C<$*N> dynamic variable is available inside the C<Callable> and is
line of the file, giving the line. By default, the line will be presented
to the code B<without> its line ending. You need to specify
C<--with-line-endings> if you want to have the line ending also.

The C<$*N> dynamic variable is available inside the C<Callable> and is
initialized to 0 (in case modifications require keeping numeric state
between calls). It is then up to the C<Callable> to return:

Expand Down
6 changes: 3 additions & 3 deletions lib/App/Rak.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -3207,7 +3207,7 @@ my sub action-modify-files(--> Nil) {
my int $nr-lines-changed;
my int $nr-lines-removed;
%rak<with-line-endings> := True unless %rak<with-line-endings>:exists;
my $joiner := %rak<with-line-endings> ?? "" !! "\n";
%rak<passthru-context> := %listing<passthru-context>:delete // True;
%rak<mapper> := -> $io, @matches --> Empty {
++$nr-files-seen;
Expand Down Expand Up @@ -3254,11 +3254,11 @@ my sub action-modify-files(--> Nil) {
if $lines-changed || $lines-removed {
unless $dryrun {
if $backup {
$io.spurt(@matches.map(*.value).join)
$io.spurt(@matches.map(*.value).join($joiner)) ~ $joiner
if $io.rename($io.sibling($io.basename ~ $backup));
}
else {
$io.spurt: @matches.map(*.value).join;
$io.spurt: @matches.map(*.value).join($joiner) ~ $joiner;
}
}
$nr-lines-changed += $lines-changed;
Expand Down
5 changes: 4 additions & 1 deletion resources/help/content.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ Else it will be kept unchanged because of an implicit --passthru-context
argument being active.

Files are presented in a sorted order, allowing for repeatable and
ordered renaming. The $*N dynamic variable (initialized to 0) is
ordered modification. The $*N dynamic variable (initialized to 0) is
available to the pattern, to allow keeping state between files.

Defaults to False, indicating that files should **not** be changed. Can
also specify --dryrun to see which files would be changed without actually
making any changes.

By default, lines will be presented **without** their line ending.
If you want to have them included, specify --with-line-endings.

--rename-files

Only makes sense with a Callable pattern. Assumes --find semantics
Expand Down

0 comments on commit 0b34264

Please sign in to comment.