https://github.com/arielhorwitz/matchpick
Find and replace multi-lines using a match-case
https://github.com/arielhorwitz/matchpick
Last synced: 3 months ago
JSON representation
Find and replace multi-lines using a match-case
- Host: GitHub
- URL: https://github.com/arielhorwitz/matchpick
- Owner: ArielHorwitz
- License: unlicense
- Created: 2024-02-07T01:09:22.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-31T17:34:03.000Z (5 months ago)
- Last Synced: 2025-04-12T19:40:38.621Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```
Find and replace multi-lines using a match-caseUsage: matchpick [OPTIONS] [FILE]
Arguments:
[FILE] Read from file (otherwise from stdin)Options:
-m, --match Match against (can be used multiple times)
-s, --start-pattern Pattern to start matching and switch cases [default: ~>>>]
-e, --end-pattern Pattern to end matching [default: ~<<<]
--ignore-pattern Pattern to ignore other patterns
-o, --output Output to file (otherwise to stdout)
--print-start Print default starting pattern
--print-end Print default ending pattern
-h, --help Print help
-V, --version Print version
```As an example, the input:
```
start
~>>>
default output
~>>> eggs
foo, foo
~>>> spam
foo? bar!
foo... baz.
~<<<
end
```
Produces with default arguments:
```
start
default output
end
```
Produces with `--match eggs`:
```
start
foo, foo
end
```
Produces with `--match spam`:
```
start
foo? bar!
foo... baz.
end
```
Produces with `--match something_else`:
```
start
default output
end
```You may specify multiple words to match with or against. This will result in the first full-word match will. For example:
```
~>>>
This will match against "gamma"
~>>> one alpha betagamma
This will match against "one", "alpha", "one two", "two one", "two beta alpha", "betagamma"
~>>> two beta
This will match against "two", "beta", "two beta", "beta two"
~<<<
```