From 2feeb2562f8ef7df479b026175edbca76219901f Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sun, 11 Aug 2024 11:16:55 +0200 Subject: [PATCH] chore(cli): Rename `files` -> `glob` Old flag remains as `alias`, so this is not breaking --- .github/workflows/main.yml | 2 +- .vscode/launch.json | 2 +- README.md | 8 ++++---- benches/bench-files.sh | 6 +++--- src/main.rs | 6 +++--- tests/cli.rs | 20 +++++++++---------- tests/files/files-python/in/1-shebanged | 2 +- tests/files/files-python/out/1-shebanged | 2 +- tests/readme.rs | 2 +- ...any-outside-search-mode-multithreaded.snap | 2 +- ...__fail-any-outside-search-mode-sorted.snap | 2 +- ...les-outside-search-mode-multithreaded.snap | 2 +- ...l-no-files-outside-search-mode-sorted.snap | 2 +- ...tly-outside-search-mode-multithreaded.snap | 2 +- ...explicitly-outside-search-mode-sorted.snap | 2 +- ...li__tests__files-inplace-python-linux.snap | 2 +- ...li__tests__files-inplace-python-macos.snap | 2 +- ...__tests__files-inplace-python-windows.snap | 2 +- ...coping-and-files-inplace-python-linux.snap | 2 +- ...coping-and-files-inplace-python-macos.snap | 2 +- ...ping-and-files-inplace-python-windows.snap | 2 +- ..._tests__python-search-stdin-and-files.snap | 2 +- 22 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85fcd042..21471c05 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,7 +88,7 @@ jobs: - run: cargo msrv verify bench-files: - name: Run benchmarks for `--files` option + name: Run benchmarks for `--glob` option runs-on: ubuntu-latest diff --git a/.vscode/launch.json b/.vscode/launch.json index d78b9534..e9a68f27 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,7 +22,7 @@ "args": [ "--python", "comments", - "--files", + "--glob", "**/strings.py" ], "cwd": "${workspaceFolder}", diff --git a/README.md b/README.md index c51ace38..307c7052 100644 --- a/README.md +++ b/README.md @@ -1076,15 +1076,15 @@ with your own queries: #### Run against multiple files -Use the `--files` option to run against multiple files, in-place. This option accepts a +Use the `--glob` option to run against multiple files, in-place. This option accepts a [glob pattern](https://docs.rs/glob/0.3.1/glob/struct.Pattern.html). The glob is processed *within `srgn`*: it must be quoted to prevent premature shell interpretation. -The `--files` option takes precedence over the heuristics of language scoping. For +The `--glob` option takes precedence over the heuristics of language scoping. For example, ```console -$ srgn --go 'comments' --files 'tests/langs/go/fizz*.go' '\w+' +$ srgn --go 'comments' --glob 'tests/langs/go/fizz*.go' '\w+' tests/langs/go/fizzbuzz.go 5:// fizzBuzz prints the numbers from 1 to a specified limit. 6:// For multiples of 3, it prints "Fizz" instead of the number, @@ -1262,7 +1262,7 @@ Standalone Actions (only usable alone): [aliases: squeeze-repeats] Options (global): - --files + --glob Glob of files to work on (instead of reading stdin). If processing occurs, it is done in-place, overwriting originals. diff --git a/benches/bench-files.sh b/benches/bench-files.sh index 0d146162..8cfc312d 100755 --- a/benches/bench-files.sh +++ b/benches/bench-files.sh @@ -23,9 +23,9 @@ bench() { hyperfine \ --warmup 1 \ - "./srgn --gitignored --fail-no-files --go comments --files 'kubernetes/**/*.go' '[tT]he (\w+)'" \ - "./srgn --gitignored --fail-no-files --python comments --files 'django/**/*.py' '[tT]he (\w+)'" \ - "./srgn --gitignored --fail-no-files --python comments --files 'pydantic/**/*.py' '[tT]he (\w+)'" + "./srgn --gitignored --fail-no-files --go comments --glob 'kubernetes/**/*.go' '[tT]he (\w+)'" \ + "./srgn --gitignored --fail-no-files --python comments --glob 'django/**/*.py' '[tT]he (\w+)'" \ + "./srgn --gitignored --fail-no-files --python comments --glob 'pydantic/**/*.py' '[tT]he (\w+)'" ) } diff --git a/src/main.rs b/src/main.rs index f284e8a8..47d9381d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,7 +102,7 @@ fn main() -> Result<()> { // See where we're reading from let input = match ( args.options.stdin_override_to.unwrap_or(is_readable_stdin), - args.options.files.clone(), + args.options.glob.clone(), language_scoper, ) { // stdin considered viable: always use it. @@ -998,8 +998,8 @@ mod cli { /// /// /// Names of processed files are written to stdout. - #[arg(long, verbatim_doc_comment)] - pub files: Option, + #[arg(long, verbatim_doc_comment, alias = "files")] + pub glob: Option, /// Fail if working on files (e.g. globbing is requested) but none are found. #[arg(long, verbatim_doc_comment, alias = "fail-empty-glob")] pub fail_no_files: bool, diff --git a/tests/cli.rs b/tests/cli.rs index 920856b5..b7224aca 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -197,7 +197,7 @@ Heizoelrueckstossabdaempfung. &[ "--python", "strings", - "--files", + "--glob", "**/*.py", "is", ], @@ -282,7 +282,7 @@ Heizoelrueckstossabdaempfung. "tests/files/files-python/in", &[ "--sorted", - "--files", + "--glob", "**/*.py", "foo", "baz" @@ -308,7 +308,7 @@ Heizoelrueckstossabdaempfung. "--sorted", "--python", "function-names", - "--files", // Will override language scoper + "--glob", // Will override language scoper "subdir/**/*.py", "foo", "baz" @@ -321,7 +321,7 @@ Heizoelrueckstossabdaempfung. &[ "--python", "function-names", - "--files", // Will override language scoper + "--glob", // Will override language scoper "subdir/**/*.py", "foo", "baz" @@ -477,7 +477,7 @@ Heizoelrueckstossabdaempfung. &[ "--sorted", "--fail-none", - "--files", + "--glob", "**/*.py", "unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih", ], @@ -501,7 +501,7 @@ Heizoelrueckstossabdaempfung. &[ "--sorted", "--fail-any", - "--files", + "--glob", "**/*.py", r".", ], @@ -525,7 +525,7 @@ Heizoelrueckstossabdaempfung. &[ "--sorted", "--fail-no-files", - "--files", + "--glob", "**/*.there-is-no-such-suffix", r".", ], @@ -559,7 +559,7 @@ Heizoelrueckstossabdaempfung. None, &[ "--fail-none", - "--files", + "--glob", "**/*.py", "unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih", ], @@ -581,7 +581,7 @@ Heizoelrueckstossabdaempfung. None, &[ "--fail-any", - "--files", + "--glob", "**/*.py", r".", ], @@ -603,7 +603,7 @@ Heizoelrueckstossabdaempfung. None, &[ "--fail-no-files", - "--files", + "--glob", "**/*.there-is-no-such-suffix", r".", ], diff --git a/tests/files/files-python/in/1-shebanged b/tests/files/files-python/in/1-shebanged index 369601ee..347bf080 100644 --- a/tests/files/files-python/in/1-shebanged +++ b/tests/files/files-python/in/1-shebanged @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -# Isn't touched by manual `--files` option +# Isn't touched by manual `--glob` option # This string is not found and touched: foo diff --git a/tests/files/files-python/out/1-shebanged b/tests/files/files-python/out/1-shebanged index 369601ee..347bf080 100644 --- a/tests/files/files-python/out/1-shebanged +++ b/tests/files/files-python/out/1-shebanged @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -# Isn't touched by manual `--files` option +# Isn't touched by manual `--glob` option # This string is not found and touched: foo diff --git a/tests/readme.rs b/tests/readme.rs index 12930ecb..bf064dc4 100644 --- a/tests/readme.rs +++ b/tests/readme.rs @@ -492,7 +492,7 @@ mod tests { tag("typescript-query"), // tag("csharp"), - tag("files"), + tag("glob"), tag("go"), tag("hcl"), tag("python"), diff --git a/tests/snapshots/cli__tests__fail-any-outside-search-mode-multithreaded.snap b/tests/snapshots/cli__tests__fail-any-outside-search-mode-multithreaded.snap index a663f24c..0c2fd5ed 100644 --- a/tests/snapshots/cli__tests__fail-any-outside-search-mode-multithreaded.snap +++ b/tests/snapshots/cli__tests__fail-any-outside-search-mode-multithreaded.snap @@ -7,7 +7,7 @@ info: --- args: - "--fail-any" - - "--files" + - "--glob" - "**/*.py" - "." stdin: ~ diff --git a/tests/snapshots/cli__tests__fail-any-outside-search-mode-sorted.snap b/tests/snapshots/cli__tests__fail-any-outside-search-mode-sorted.snap index 6ed73fdc..0ac23e06 100644 --- a/tests/snapshots/cli__tests__fail-any-outside-search-mode-sorted.snap +++ b/tests/snapshots/cli__tests__fail-any-outside-search-mode-sorted.snap @@ -8,7 +8,7 @@ info: args: - "--sorted" - "--fail-any" - - "--files" + - "--glob" - "**/*.py" - "." stdin: ~ diff --git a/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-multithreaded.snap b/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-multithreaded.snap index 2c61bf84..c8a26da5 100644 --- a/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-multithreaded.snap +++ b/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-multithreaded.snap @@ -7,7 +7,7 @@ info: --- args: - "--fail-no-files" - - "--files" + - "--glob" - "**/*.there-is-no-such-suffix" - "." stdin: ~ diff --git a/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-sorted.snap b/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-sorted.snap index 9b4b03e3..75b31314 100644 --- a/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-sorted.snap +++ b/tests/snapshots/cli__tests__fail-no-files-outside-search-mode-sorted.snap @@ -8,7 +8,7 @@ info: args: - "--sorted" - "--fail-no-files" - - "--files" + - "--glob" - "**/*.there-is-no-such-suffix" - "." stdin: ~ diff --git a/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-multithreaded.snap b/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-multithreaded.snap index 7c119f4d..188530c3 100644 --- a/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-multithreaded.snap +++ b/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-multithreaded.snap @@ -7,7 +7,7 @@ info: --- args: - "--fail-none" - - "--files" + - "--glob" - "**/*.py" - unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih stdin: ~ diff --git a/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-sorted.snap b/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-sorted.snap index ef468123..0a869804 100644 --- a/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-sorted.snap +++ b/tests/snapshots/cli__tests__fail-none-explicitly-outside-search-mode-sorted.snap @@ -8,7 +8,7 @@ info: args: - "--sorted" - "--fail-none" - - "--files" + - "--glob" - "**/*.py" - unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih stdin: ~ diff --git a/tests/snapshots/cli__tests__files-inplace-python-linux.snap b/tests/snapshots/cli__tests__files-inplace-python-linux.snap index 77c4f320..fdcb5bfd 100644 --- a/tests/snapshots/cli__tests__files-inplace-python-linux.snap +++ b/tests/snapshots/cli__tests__files-inplace-python-linux.snap @@ -6,7 +6,7 @@ info: --- args: - "--sorted" - - "--files" + - "--glob" - "**/*.py" - foo - baz diff --git a/tests/snapshots/cli__tests__files-inplace-python-macos.snap b/tests/snapshots/cli__tests__files-inplace-python-macos.snap index 77c4f320..fdcb5bfd 100644 --- a/tests/snapshots/cli__tests__files-inplace-python-macos.snap +++ b/tests/snapshots/cli__tests__files-inplace-python-macos.snap @@ -6,7 +6,7 @@ info: --- args: - "--sorted" - - "--files" + - "--glob" - "**/*.py" - foo - baz diff --git a/tests/snapshots/cli__tests__files-inplace-python-windows.snap b/tests/snapshots/cli__tests__files-inplace-python-windows.snap index ed996eab..93c4fc3c 100644 --- a/tests/snapshots/cli__tests__files-inplace-python-windows.snap +++ b/tests/snapshots/cli__tests__files-inplace-python-windows.snap @@ -6,7 +6,7 @@ info: --- args: - "--sorted" - - "--files" + - "--glob" - "**/*.py" - foo - baz diff --git a/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-linux.snap b/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-linux.snap index 29c59572..09b14337 100644 --- a/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-linux.snap +++ b/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-linux.snap @@ -8,7 +8,7 @@ args: - "--sorted" - "--python" - function-names - - "--files" + - "--glob" - subdir/**/*.py - foo - baz diff --git a/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-macos.snap b/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-macos.snap index 29c59572..09b14337 100644 --- a/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-macos.snap +++ b/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-macos.snap @@ -8,7 +8,7 @@ args: - "--sorted" - "--python" - function-names - - "--files" + - "--glob" - subdir/**/*.py - foo - baz diff --git a/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-windows.snap b/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-windows.snap index 41b6ee3f..1ea7fa7a 100644 --- a/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-windows.snap +++ b/tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-windows.snap @@ -8,7 +8,7 @@ args: - "--sorted" - "--python" - function-names - - "--files" + - "--glob" - subdir/**/*.py - foo - baz diff --git a/tests/snapshots/cli__tests__python-search-stdin-and-files.snap b/tests/snapshots/cli__tests__python-search-stdin-and-files.snap index 65a0fa5e..8de46fd9 100644 --- a/tests/snapshots/cli__tests__python-search-stdin-and-files.snap +++ b/tests/snapshots/cli__tests__python-search-stdin-and-files.snap @@ -7,7 +7,7 @@ info: args: - "--python" - strings - - "--files" + - "--glob" - "**/*.py" - is stdin: