diff --git a/Changes b/Changes index d74e95a..6fd0daf 100644 --- a/Changes +++ b/Changes @@ -1,8 +1,10 @@ Revision history for App-Rak {{$NEXT}} + - Added support for --ack to activate a compatibility + layer for former "ack" users. - Added dependency on Needle::Compile to handle all the - pattern to Callable issues + pattern to Callable issues (just for CI for now) - Upped all dependencies where applicable - Hoperfully fixed Windows CI for now diff --git a/README.md b/README.md index 174a73a..dec567f 100644 --- a/README.md +++ b/README.md @@ -364,6 +364,18 @@ If specified, indicates the `Callable` that should return True to include a file See "CHECKING TIMES ON FILES" for more information about features that can be used inside the `Callable`. +--ack +----- + +Attempt to interpret following arguments as if they were arguments to the [`ack`](https://metacpan.org/pod/ack) utility. This is incomplete and may be subtly different in behaviour. Intended as a temporary measure for people used to using `ack`, while they train their muscle memory to use **rak** instead. + +If you'd like a list of the option configuration, you can use the `--list-custom-options` argument. + +```bash +# Show the current mappinng of "ack" to "rak" options +$ rak --ack --list-custom-options +``` + --after-context=N ----------------- diff --git a/doc/App-Rak.rakudoc b/doc/App-Rak.rakudoc index 3257578..62234e2 100644 --- a/doc/App-Rak.rakudoc +++ b/doc/App-Rak.rakudoc @@ -478,6 +478,24 @@ reliably. See "CHECKING TIMES ON FILES" for more information about features that can be used inside the C. +=head2 --ack + +Attempt to interpret following arguments as if they were arguments to the +L|https://metacpan.org/pod/ack> utility. This is incomplete and +may be subtly different in behaviour. Intended as a temporary measure +for people used to using C, while they train their muscle memory +to use B instead. + +If you'd like a list of the option configuration, you can use the +C<--list-custom-options> argument. + +=begin code :lang + +# Show the current mappinng of "ack" to "rak" options +$ rak --ack --list-custom-options + +=end code + =head2 --after-context=N Indicate the number of lines that should be shown B any line that diff --git a/lib/App/Rak.rakumod b/lib/App/Rak.rakumod index 4e14a3e..e2eae60 100644 --- a/lib/App/Rak.rakumod +++ b/lib/App/Rak.rakumod @@ -23,9 +23,9 @@ my constant BON = "\e[1m"; # BOLD ON my constant BOFF = "\e[22m"; # BOLD OFF #- start of available options -------------------------------------------------- -#- Generated on 2024-05-12T20:26:03+02:00 by tools/makeOPTIONS.raku +#- Generated on 2024-08-04T16:31:51+02:00 by tools/makeOPTIONS.raku #- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE -my str @options = ; +my str @options = ; #- PLEASE DON'T CHANGE ANYTHING ABOVE THIS LINE #- end of available options ---------------------------------------------------- @@ -91,6 +91,52 @@ my constant %falsies = unrestricted => 'dir', ; +# The JSON config to map "ack" arguments to "rak" arguments as closely as possible +my constant %ack-interface-config = + "1" => (:only-first,), + "A" => (:after-context,), + "B" => (:before-context,), + "c" => (:count-only,), + "C" => (:context<[2]>,), + "count" => (:count-only,), + "dump" => (:list-expanded-options,), + "f" => (:find,), + "filename" => (:show-filename,), + "follow" => (:recurse-symlinked-dir,), + "group" => (:group-matches,), + "h" => (:!show-filename,), + "H" => (:show-filename,), + "heading" => (:group-matches,), + "help-types" => (:extensions<[*]>,), + "i" => (:ignorecase,), + "I" => (:!ignorecase,), + "ignore-case" => (:ignorecase,), + "ignore-dir" => (:dir,), + "ignore-directory" => (:dir,), + "k" => (:extensions<[*]>,), + "known-types" => (:extensions<[*]>,), + "l" => (:files-with-matches,), + "L" => (:files-without-matches,), + "m" => (:max-matches-per-file,), + "n" => (:!dir,), + "man" => (:help,), + "match" => (:pattern,), + "max-count" => (:max-matches-per-file,), + "o" => (:matches-only,), + "output" => (:pattern,), + "p" => (:proximate,), + "P" => (:proximate<0>,), + "print0" => (:file-separator-null,), + "S" => (:smartcase,), + "smart-case" => (:smartcase,), + "t" => (:extensions,), + "type" => (:extensions,), + "TYPE" => (:extensions,), + "v" => (:invert-match,), + "with-filename" => (:show-filename,), + "x" => (:files-from<->,), +; + # Options that only make sense after one main option my constant %sub-options = allow-loose-escapes => 'csv-per-line', @@ -1526,6 +1572,10 @@ my sub option-accessed($value --> Nil) { set-filesystem-Instant('accessed', $value) } +my sub option-ack($value --> Nil) { + %config := %ack-interface-config; +} + my sub option-after-context($value --> Nil) { set-result-Int('after-context', $value); } diff --git a/resources/help.txt b/resources/help.txt index 2b9b2d2..db2fe9d 100644 --- a/resources/help.txt +++ b/resources/help.txt @@ -173,6 +173,7 @@ Option management: --save=name Translate --name to all other options specified, remove if --save was the only option specified --description=text Add description to custom option + --ack Activate "ack" compatibility options --list-custom-options List all previously saved options General options: diff --git a/resources/help/option.txt b/resources/help/option.txt index 6ad78ca..9700b9e 100644 --- a/resources/help/option.txt +++ b/resources/help/option.txt @@ -71,6 +71,14 @@ $ rak --description="Perform search without regards to case" --save=i # Add custom option --y with description $ rak --description='Yep, there is a codepoint for it' --unicode --save=y +--ack + +Attempt to interpret following arguments as if they were arguments to the +"ack" utility. This is incomplete and may be subtly different in behaviour. +Intended as a temporary measure for people used to using "ack", while they +train their muscle memory to use "rak" instead. + --list-custom-options -List all currently known custom options. Must be the only argument. +List all currently known custom options. Must be the only argument, but +can also be used in conjunction with --ack.