Skip to content

Commit

Permalink
Better options
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrw committed Feb 23, 2018
1 parent 83c0ceb commit 55c9dcb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,29 @@ RexReplace normally treats `€` as an alias for `$` so the following will do th
Please update to version 3 as several flags have been altered (for the better) since version 2. Most noticeable: the `-J` flag has merged into the `-j` flag and the function of `-O` must now be obtained via `-m`.


Flag | Option name | Effect
---- | ---- | ----
`-v` | `--version` | Print rexreplace version (can be given as only argument) [boolean]
`-V` | `--verbose` | More chatty output [boolean]
`-I` | `--void-ignore-case` | Void case insensitive search pattern. [boolean]
`-G` | `--void-global` | Void global search (work only with first the match). [boolean]
`-M` | `--void-multiline` | Void multiline search pattern. Makes ^ and $ match start/end of whole content rather than each line. [boolean]
`-u` | `--unicode` | Treat pattern as a sequence of unicode code points. [boolean]
`-e` | `--encoding` | Encoding of files/piped data. [default: "utf8"]
`-q` | `--quiet` | Only display errors (no other info) [boolean]
`-Q` | `--quiet-total` | Never display errors or info [boolean]
`-H` | `--halt` | Halt on first error [boolean] [default: false]
`-d` | `--debug` | Print debug info [boolean]
`-€` | `--void-euro` | Void having `` as alias for `$` in pattern and replacement parameters [boolean]
`-o` | `--output` | Output the final result instead of saving to file. Will also output content even if no replacement has taken place. [boolean]
`-A` | `--void-async` | Handle files in a synchronous flow. Good to limit memory usage when handling large files. [boolean]
`-B` | `--void-backup` | Avoid temporary backing up file. Works async (independent of -A flag) and will speed up things but at one point data lives only in memory and you will lose the content if the process is abrupted. [boolean]
`-b` | `--keep-backup` | Keep a backup file of the original content. [boolean]
`-m` | `--output-match` | Output each match on a new line. Will not replace any content but you still need to provide a dummy value (like `_`) as replacement parameter. If search pattern does not contain matching groups the full match will be outputted. If search pattern does contain matching groups only matching groups will be outputted (same line with no delimiter). [boolean]
`-T` | `--trim-pipe` | Trim piped data before processing. If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be considered an empty string. [boolean]
`-R` | `--replacement-pipe` | Replacement will be piped in. You still need to provide a dummy value (like `_`) as replacement parameter. [boolean]
`-j` | `--replacement-js` | Treat replacement as javascript source code. The statement from the last expression will become the replacement string. Purposefully implemented the most insecure way possible to remove _any_ incentive to consider running code from an untrusted person - that be anyone that is not yourself. The full match will be available as a javascript variable named $0 while each captured group will be avaiable as $1, $2, $3, ... and so on. At some point the $ char _will_ give you a headache when used from the command line, so use €0, €1, €2 €3 ... instead. If the javascript source code references to the full match or a captured group the code will run once per match. Otherwise it will run once per file. The code has access to the following variables: `_fs` from node, `_globs` from npm, `_pipe` is the piped data into the command (null if no piped data), `_find` is the final pattern searched for. `_text` is the full text being searched (Corresponds to file contents or piped data).The following values are also available if working on a file (if data is being piped they are all set to an empty string): `_file` is the full path of the active file being searched (including full filename), `_path` is the full path without filename of the active file being searched, `_filename` is the full filename of the active file being searched, `_name` is the filename of the active file being searched with no extension, `_ext` is the extension of the filename including leading dot. [boolean]
`-h` | `--help` | Display help. [boolean]
Flag | Effect
---- | ----
`-v` | **`--version`** Print rexreplace version (can be given as only argument) [boolean]
`-V` | **`--verbose`** More chatty output [boolean]
`-I` | **`--void-ignore-case`** Void case insensitive search pattern. [boolean]
`-G` | **`--void-global`** Void global search (work only with first the match). [boolean]
`-M` | **`--void-multiline`** Void multiline search pattern. Makes ^ and $ match start/end of whole content rather than each line. [boolean]
`-u` | **`--unicode`** Treat pattern as a sequence of unicode code points. [boolean]
`-e` | **`--encoding`** Encoding of files/piped data. [default: "utf8"]
`-q` | **`--quiet`** Only display errors (no other info) [boolean]
`-Q` | **`--quiet-total`** Never display errors or info [boolean]
`-H` | **`--halt`** Halt on first error [boolean] [default: false]
`-d` | **`--debug`** Print debug info [boolean]
`-€` | **`--void-euro`** Void having `` as alias for `$` in pattern and replacement parameters [boolean]
`-o` | **`--output`** Output the final result instead of saving to file. Will also output content even if no replacement has taken place. [boolean]
`-A` | **`--void-async`** Handle files in a synchronous flow. Good to limit memory usage when handling large files. [boolean]
`-B` | **`--void-backup`** Avoid temporary backing up file. Works async (independent of -A flag) and will speed up things but at one point data lives only in memory and you will lose the content if the process is abrupted. [boolean]
`-b` | **`--keep-backup`** Keep a backup file of the original content. [boolean]
`-m` | **`--output-match`** Output each match on a new line. Will not replace any content but you still need to provide a dummy value (like `_`) as replacement parameter. If search pattern does not contain matching groups the full match will be outputted. If search pattern does contain matching groups only matching groups will be outputted (same line with no delimiter). [boolean]
`-T` | **`--trim-pipe`** Trim piped data before processing. If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be considered an empty string. [boolean]
`-R` | **`--replacement-pipe`** Replacement will be piped in. You still need to provide a dummy value (like `_`) as replacement parameter. [boolean]
`-j` | **`--replacement-js`** Treat replacement as javascript source code. The statement from the last expression will become the replacement string. Purposefully implemented the most insecure way possible to remove _any_ incentive to consider running code from an untrusted person - that be anyone that is not yourself. The full match will be available as a javascript variable named $0 while each captured group will be avaiable as $1, $2, $3, ... and so on. At some point the $ char _will_ give you a headache when used from the command line, so use €0, €1, €2 €3 ... instead. If the javascript source code references to the full match or a captured group the code will run once per match. Otherwise it will run once per file. The code has access to the following variables: `_fs` from node, `_globs` from npm, `_pipe` is the piped data into the command (null if no piped data), `_find` is the final pattern searched for. `_text` is the full text being searched (Corresponds to file contents or piped data).The following values are also available if working on a file (if data is being piped they are all set to an empty string): `_file` is the full path of the active file being searched (including full filename), `_path` is the full path without filename of the active file being searched, `_filename` is the full filename of the active file being searched, `_name` is the filename of the active file being searched with no extension, `_ext` is the extension of the filename including leading dot. [boolean]
`-h` | **`--help`** Display help. [boolean]
## Good to know

### Features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test-speed": "bash test/speed/run.sh",
"prepack": "git pull && npm test ",
"postpublish": "git add --all && git commit -m v$(node -e 'console.log(require(`./package.json`).version)') && git tag v$(node -e 'console.log(require(`./package.json`).version)') && git push && git push --tag && (open https://github.com/mathiasrw/rexreplace/releases || 1)",
"options":"rr -h | rr 'Options:([\\s\\S]+)Examples:' _ -m | rr '\n {26,}' ' ' | rr \"'\" '`' | rr '^ (-.+?), (--[^ ]+) *' '`€1` | `€2` | ' | rr '(---- . ---- . ----\n)[\\s\\S]*?(\n## Good to know)' '€1 + _pipe + €2' readme.md -jT"
"options":"rr -h | rr 'Options:([\\s\\S]+)Examples:' _ -m | rr '\n {26,}' ' ' | rr \"'\" '`' | rr '^ (-.+?), (--[^ ]+) *' '`€1` | **`€2`** ' | rr '(^---- . ----\n)[\\s\\S]*?(\n## Good to know)' '€1 + _pipe + €2' readme.md -jT"
},
"keywords": [
"replace",
Expand Down

0 comments on commit 55c9dcb

Please sign in to comment.