Crates.io | replacer-cli |
lib.rs | replacer-cli |
version | 0.2.0 |
source | src |
created_at | 2024-09-16 23:07:29.026202 |
updated_at | 2024-10-18 16:21:41.941459 |
description | A flexible cli to replace strings in files or a directory |
homepage | |
repository | https://github.com/Tnixc/replacer |
max_upload_size | |
id | 1376973 |
size | 28,188 |
A BLAZINGLy FAST CLI tool written in Rust to replace strings in files or stdin, recursively and quickly.
cargo install replacer-cli
replacer [FLAGS] [OPTIONS] [TARGET]
If no TARGET is specified, Replacer will process input from stdin and write to stdout.
-s, --case-insensitive
: Make replacements case-insensitive-h, --help
: Print help information-V, --version
: Print version information-c, --config <FILE>
: Path to the config file (default: "replacer.config.toml")-i, --ignore <PATHS>...
: Ignore directories or files-n, --no-ignore <PATHS>...
: Don't ignore directories or files (overrides ignore config)-p, --pair <KEY=VALUE>
: Additional replacement pairs (format: key=value)<TARGET>
: Path to the target file or directory (omit for stdin)You can use a configuration file (default: replacer.config.toml
) in the following format:
# replacer.config.toml
pairs = [
["old text 1", "new text 1"],
["foo", "bar"]
]
case_sensitive = true # Optional, defaults to true
# Ignore Configuration (Optional)
ignore = [".git", "dist", ".env", "ignore_this.txt", "*.ignore"]
Replace text in a directory using a config file:
replacer ./path/to/target
Replace text from stdin:
echo "Hello, world!" | replacer
Use CLI arguments for replacement pairs:
replacer -p "foo=bar" -p "old=new" ./path/to/target
Ignore specific directories:
replacer -i node_modules -i .git ./path/to/target
Override ignore settings:
replacer -n important_file.txt ./path/to/target
Case-insensitive replacement:
replacer -s -p "HELLO=world" ./path/to/target
--
after flags which take in PATHS (such as -i) to continue the args..git
directory is ignored by default.*.log
or temp*
.