diff --git a/Cargo.lock b/Cargo.lock index 8aeef89..1e28893 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -318,30 +318,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "globset" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" -dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", -] - -[[package]] -name = "globwalk" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" -dependencies = [ - "bitflags 1.3.2", - "ignore", - "walkdir", -] - [[package]] name = "heck" version = "0.4.1" @@ -354,23 +330,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" -[[package]] -name = "ignore" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" -dependencies = [ - "globset", - "lazy_static", - "log", - "memchr", - "regex", - "same-file", - "thread_local", - "walkdir", - "winapi-util", -] - [[package]] name = "insta" version = "1.34.0" @@ -434,12 +393,6 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - [[package]] name = "memchr" version = "2.6.4" @@ -474,12 +427,6 @@ dependencies = [ "libm", ] -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -692,15 +639,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -718,8 +656,6 @@ dependencies = [ "clap", "clap_mangen", "console", - "globwalk", - "ignore", "insta", "is-terminal", "memmap2", @@ -824,16 +760,6 @@ dependencies = [ "syn", ] -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "unarray" version = "0.1.4" @@ -873,16 +799,6 @@ dependencies = [ "libc", ] -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -905,15 +821,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 1d9ab60..25032bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,8 +33,6 @@ unescape = "0.1.0" memmap2 = "0.9.0" tempfile = "3.8.0" thiserror = "1.0.50" -globwalk = "0.8.1" -ignore = "0.4.20" ansi_term = "0.12.1" is-terminal = "0.4.9" clap.workspace = true diff --git a/gen/completions/_sd b/gen/completions/_sd index 5aade10..e8f2804 100644 --- a/gen/completions/_sd +++ b/gen/completions/_sd @@ -18,16 +18,15 @@ _sd() { '-n+[Limit the number of replacements]:REPLACEMENTS: ' \ '-f+[Regex flags. May be combined (like \`-f mc\`).]:FLAGS: ' \ '--flags=[Regex flags. May be combined (like \`-f mc\`).]:FLAGS: ' \ -'-p[Output result into stdout and do not modify files]' \ -'--preview[Output result into stdout and do not modify files]' \ +'-p[Display changes in a human reviewable format (the specifics of the format are likely to change in the future)]' \ +'--preview[Display changes in a human reviewable format (the specifics of the format are likely to change in the future)]' \ '-F[Treat FIND and REPLACE_WITH args as literal strings]' \ '--fixed-strings[Treat FIND and REPLACE_WITH args as literal strings]' \ -'-r[Recursively replace files]' \ '-h[Print help (see more with '\''--help'\'')]' \ '--help[Print help (see more with '\''--help'\'')]' \ '-V[Print version]' \ '--version[Print version]' \ -':find -- The regexp or string (if -s) to search for:' \ +':find -- The regexp or string (if using `-F`) to search for:' \ ':replace_with -- What to replace each match with. Unless in string mode, you may use captured values like $1, $2, etc:' \ '*::files -- The path to file(s). This is optional - sd can also read from STDIN:_files' \ && ret=0 diff --git a/gen/completions/_sd.ps1 b/gen/completions/_sd.ps1 index 01e4658..4704172 100644 --- a/gen/completions/_sd.ps1 +++ b/gen/completions/_sd.ps1 @@ -24,11 +24,10 @@ Register-ArgumentCompleter -Native -CommandName 'sd' -ScriptBlock { [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Limit the number of replacements') [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Regex flags. May be combined (like `-f mc`).') [CompletionResult]::new('--flags', 'flags', [CompletionResultType]::ParameterName, 'Regex flags. May be combined (like `-f mc`).') - [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Output result into stdout and do not modify files') - [CompletionResult]::new('--preview', 'preview', [CompletionResultType]::ParameterName, 'Output result into stdout and do not modify files') + [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)') + [CompletionResult]::new('--preview', 'preview', [CompletionResultType]::ParameterName, 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)') [CompletionResult]::new('-F', 'F ', [CompletionResultType]::ParameterName, 'Treat FIND and REPLACE_WITH args as literal strings') [CompletionResult]::new('--fixed-strings', 'fixed-strings', [CompletionResultType]::ParameterName, 'Treat FIND and REPLACE_WITH args as literal strings') - [CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Recursively replace files') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') diff --git a/gen/completions/sd.bash b/gen/completions/sd.bash index 412f19e..78eae05 100644 --- a/gen/completions/sd.bash +++ b/gen/completions/sd.bash @@ -19,7 +19,7 @@ _sd() { case "${cmd}" in sd) - opts="-p -F -r -n -f -h -V --preview --fixed-strings --flags --help --version [FILES]..." + opts="-p -F -n -f -h -V --preview --fixed-strings --flags --help --version [FILES]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/gen/completions/sd.elv b/gen/completions/sd.elv index 3aaa7fb..e455cc0 100644 --- a/gen/completions/sd.elv +++ b/gen/completions/sd.elv @@ -21,11 +21,10 @@ set edit:completion:arg-completer[sd] = {|@words| cand -n 'Limit the number of replacements' cand -f 'Regex flags. May be combined (like `-f mc`).' cand --flags 'Regex flags. May be combined (like `-f mc`).' - cand -p 'Output result into stdout and do not modify files' - cand --preview 'Output result into stdout and do not modify files' + cand -p 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)' + cand --preview 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)' cand -F 'Treat FIND and REPLACE_WITH args as literal strings' cand --fixed-strings 'Treat FIND and REPLACE_WITH args as literal strings' - cand -r 'Recursively replace files' cand -h 'Print help (see more with ''--help'')' cand --help 'Print help (see more with ''--help'')' cand -V 'Print version' diff --git a/gen/completions/sd.fish b/gen/completions/sd.fish index f99fd43..a0e03ab 100644 --- a/gen/completions/sd.fish +++ b/gen/completions/sd.fish @@ -1,7 +1,6 @@ complete -c sd -s n -d 'Limit the number of replacements' -r complete -c sd -s f -l flags -d 'Regex flags. May be combined (like `-f mc`).' -r -complete -c sd -s p -l preview -d 'Output result into stdout and do not modify files' +complete -c sd -s p -l preview -d 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)' complete -c sd -s F -l fixed-strings -d 'Treat FIND and REPLACE_WITH args as literal strings' -complete -c sd -s r -d 'Recursively replace files' complete -c sd -s h -l help -d 'Print help (see more with \'--help\')' complete -c sd -s V -l version -d 'Print version' diff --git a/gen/sd.1 b/gen/sd.1 index c5d92ff..3c3916b 100644 --- a/gen/sd.1 +++ b/gen/sd.1 @@ -8,7 +8,7 @@ sd .ie \n(.g .ds Aq \(aq .el .ds Aq ' .SH SYNOPSIS -\fBsd\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-F\fR|\fB\-\-fixed\-strings\fR] [\fB\-r \fR] [\fB\-n \fR] [\fB\-f\fR|\fB\-\-flags\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIFIND\fR> <\fIREPLACE_WITH\fR> [\fIFILES\fR] +\fBsd\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-F\fR|\fB\-\-fixed\-strings\fR] [\fB\-n \fR] [\fB\-f\fR|\fB\-\-flags\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIFIND\fR> <\fIREPLACE_WITH\fR> [\fIFILES\fR] .ie \n(.g .ds Aq \(aq .el .ds Aq ' .SH DESCRIPTION @@ -17,14 +17,11 @@ sd .SH OPTIONS .TP \fB\-p\fR, \fB\-\-preview\fR -Output result into stdout and do not modify files +Display changes in a human reviewable format (the specifics of the format are likely to change in the future) .TP \fB\-F\fR, \fB\-\-fixed\-strings\fR Treat FIND and REPLACE_WITH args as literal strings .TP -\fB\-r\fR -Recursively replace files -.TP \fB\-n\fR=\fIREPLACEMENTS\fR Limit the number of replacements .TP @@ -50,7 +47,7 @@ Print help (see a summary with \*(Aq\-h\*(Aq) Print version .TP <\fIFIND\fR> -The regexp or string (if \-s) to search for +The regexp or string (if using `\-F`) to search for .TP <\fIREPLACE_WITH\fR> What to replace each match with. Unless in string mode, you may use captured values like $1, $2, etc diff --git a/src/cli.rs b/src/cli.rs index 101ab0d..dff7678 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -29,10 +29,6 @@ pub struct Options { /// Treat FIND and REPLACE_WITH args as literal strings pub literal_mode: bool, - #[arg(short)] - /// Recursively replace files - pub recursive: bool, - #[arg(short = 'n')] /// Limit the number of replacements pub replacements: Option, diff --git a/src/input.rs b/src/input.rs index a558b42..79a174d 100644 --- a/src/input.rs +++ b/src/input.rs @@ -10,23 +10,6 @@ pub(crate) enum Source { Files(Vec), } -impl Source { - pub(crate) fn recursive() -> Result { - Ok(Self::Files( - ignore::WalkBuilder::new(".") - .hidden(false) - .filter_entry(|e| e.file_name() != ".git") - .build() - .filter_map(|d| d.ok()) - .filter_map(|d| match d.file_type() { - Some(t) if t.is_file() => Some(d.into_path()), - _ => None, - }) - .collect(), - )) - } -} - pub(crate) struct App { replacer: Replacer, source: Source, diff --git a/src/main.rs b/src/main.rs index c7097b4..07c48b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,9 +24,7 @@ fn main() { fn try_main() -> Result<()> { let options = cli::Options::parse(); - let source = if options.recursive { - Source::recursive()? - } else if !options.files.is_empty() { + let source = if !options.files.is_empty() { Source::Files(options.files) } else { Source::Stdin