Skip to content

Commit

Permalink
chore(cli): Rename files -> glob
Browse files Browse the repository at this point in the history
Old flag remains as `alias`, so this is not breaking
  • Loading branch information
alexpovel committed Aug 11, 2024
1 parent ff615cc commit 2feeb25
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"args": [
"--python",
"comments",
"--files",
"--glob",
"**/strings.py"
],
"cwd": "${workspaceFolder}",
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,

<!-- markdownlint-disable MD010 -->
```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,
Expand Down Expand Up @@ -1262,7 +1262,7 @@ Standalone Actions (only usable alone):
[aliases: squeeze-repeats]

Options (global):
--files <FILES>
--glob <GLOB>
Glob of files to work on (instead of reading stdin).
If processing occurs, it is done in-place, overwriting originals.
Expand Down
6 changes: 3 additions & 3 deletions benches/bench-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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+)'"
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -998,8 +998,8 @@ mod cli {
/// <https://docs.rs/glob/0.3.1/glob/struct.Pattern.html>
///
/// Names of processed files are written to stdout.
#[arg(long, verbatim_doc_comment)]
pub files: Option<glob::Pattern>,
#[arg(long, verbatim_doc_comment, alias = "files")]
pub glob: Option<glob::Pattern>,
/// 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,
Expand Down
20 changes: 10 additions & 10 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Heizoelrueckstossabdaempfung.
&[
"--python",
"strings",
"--files",
"--glob",
"**/*.py",
"is",
],
Expand Down Expand Up @@ -282,7 +282,7 @@ Heizoelrueckstossabdaempfung.
"tests/files/files-python/in",
&[
"--sorted",
"--files",
"--glob",
"**/*.py",
"foo",
"baz"
Expand All @@ -308,7 +308,7 @@ Heizoelrueckstossabdaempfung.
"--sorted",
"--python",
"function-names",
"--files", // Will override language scoper
"--glob", // Will override language scoper
"subdir/**/*.py",
"foo",
"baz"
Expand All @@ -321,7 +321,7 @@ Heizoelrueckstossabdaempfung.
&[
"--python",
"function-names",
"--files", // Will override language scoper
"--glob", // Will override language scoper
"subdir/**/*.py",
"foo",
"baz"
Expand Down Expand Up @@ -477,7 +477,7 @@ Heizoelrueckstossabdaempfung.
&[
"--sorted",
"--fail-none",
"--files",
"--glob",
"**/*.py",
"unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih",
],
Expand All @@ -501,7 +501,7 @@ Heizoelrueckstossabdaempfung.
&[
"--sorted",
"--fail-any",
"--files",
"--glob",
"**/*.py",
r".",
],
Expand All @@ -525,7 +525,7 @@ Heizoelrueckstossabdaempfung.
&[
"--sorted",
"--fail-no-files",
"--files",
"--glob",
"**/*.there-is-no-such-suffix",
r".",
],
Expand Down Expand Up @@ -559,7 +559,7 @@ Heizoelrueckstossabdaempfung.
None,
&[
"--fail-none",
"--files",
"--glob",
"**/*.py",
"unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih",
],
Expand All @@ -581,7 +581,7 @@ Heizoelrueckstossabdaempfung.
None,
&[
"--fail-any",
"--files",
"--glob",
"**/*.py",
r".",
],
Expand All @@ -603,7 +603,7 @@ Heizoelrueckstossabdaempfung.
None,
&[
"--fail-no-files",
"--files",
"--glob",
"**/*.there-is-no-such-suffix",
r".",
],
Expand Down
2 changes: 1 addition & 1 deletion tests/files/files-python/in/1-shebanged
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/files/files-python/out/1-shebanged
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ mod tests {
tag("typescript-query"),
//
tag("csharp"),
tag("files"),
tag("glob"),
tag("go"),
tag("hcl"),
tag("python"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
---
args:
- "--fail-any"
- "--files"
- "--glob"
- "**/*.py"
- "."
stdin: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
args:
- "--sorted"
- "--fail-any"
- "--files"
- "--glob"
- "**/*.py"
- "."
stdin: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
---
args:
- "--fail-no-files"
- "--files"
- "--glob"
- "**/*.there-is-no-such-suffix"
- "."
stdin: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
args:
- "--sorted"
- "--fail-no-files"
- "--files"
- "--glob"
- "**/*.there-is-no-such-suffix"
- "."
stdin: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
---
args:
- "--fail-none"
- "--files"
- "--glob"
- "**/*.py"
- unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih
stdin: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
args:
- "--sorted"
- "--fail-none"
- "--files"
- "--glob"
- "**/*.py"
- unfindable-string-dheuihiuhiulerfiuehrilufhiusdho438ryh9vuoih
stdin: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
---
args:
- "--sorted"
- "--files"
- "--glob"
- "**/*.py"
- foo
- baz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
---
args:
- "--sorted"
- "--files"
- "--glob"
- "**/*.py"
- foo
- baz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
---
args:
- "--sorted"
- "--files"
- "--glob"
- "**/*.py"
- foo
- baz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ args:
- "--sorted"
- "--python"
- function-names
- "--files"
- "--glob"
- subdir/**/*.py
- foo
- baz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ args:
- "--sorted"
- "--python"
- function-names
- "--files"
- "--glob"
- subdir/**/*.py
- foo
- baz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ args:
- "--sorted"
- "--python"
- function-names
- "--files"
- "--glob"
- subdir/**/*.py
- foo
- baz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
args:
- "--python"
- strings
- "--files"
- "--glob"
- "**/*.py"
- is
stdin:
Expand Down

0 comments on commit 2feeb25

Please sign in to comment.