Skip to content

Commit

Permalink
chore(cli): Rename fail-empty-glob -> fail-no-files
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 9673678 commit ff615cc
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,8 @@ Options (global):
Names of processed files are written to stdout.

--fail-empty-glob
Fail if file globbing is requested but returns no matches.
--fail-no-files
Fail if working on files (e.g. globbing is requested) but none are found.

-i, --invert
Undo the effects of passed actions, where applicable
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-empty-glob --go comments --files 'kubernetes/**/*.go' '[tT]he (\w+)'" \
"./srgn --gitignored --fail-empty-glob --python comments --files 'django/**/*.py' '[tT]he (\w+)'" \
"./srgn --gitignored --fail-empty-glob --python comments --files 'pydantic/**/*.py' '[tT]he (\w+)'"
"./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+)'"
)
}

Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ fn handle_actions_on_many_files_sorted(
info!("Saw {} items", n_files_seen);
info!("Processed {} files", n_files_processed);

if n_files_seen == 0 && args.options.fail_empty_glob {
if n_files_seen == 0 && args.options.fail_no_files {
Err(ProgramError::NoFilesFound)
} else if n_files_processed == 0 && args.options.fail_none {
Err(ProgramError::NothingProcessed)
Expand Down Expand Up @@ -429,7 +429,7 @@ fn handle_actions_on_many_files_threaded(
let n_files_processed = *n_files_processed.lock().unwrap();
info!("Processed {} files", n_files_processed);

if n_files_seen == 0 && args.options.fail_empty_glob {
if n_files_seen == 0 && args.options.fail_no_files {
Err(ProgramError::NoFilesFound)
} else if n_files_processed == 0 && args.options.fail_none {
Err(ProgramError::NothingProcessed)
Expand Down Expand Up @@ -1000,9 +1000,9 @@ mod cli {
/// Names of processed files are written to stdout.
#[arg(long, verbatim_doc_comment)]
pub files: Option<glob::Pattern>,
/// Fail if file globbing is requested but returns no matches.
#[arg(long, verbatim_doc_comment)]
pub fail_empty_glob: bool,
/// 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,
/// Undo the effects of passed actions, where applicable
///
/// Requires a 1:1 mapping (bijection) between replacements and original, which
Expand Down
16 changes: 8 additions & 8 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,23 +508,23 @@ Heizoelrueckstossabdaempfung.
None,
)]
#[case(
"fail-empty-glob-in-search-mode-sorted",
"fail-no-files-in-search-mode-sorted",
None,
&[
"--sorted",
"--fail-empty-glob",
"--fail-no-files",
"--python",
"strings",
r".",
],
Some(Path::new("tests/langs/go")), // No Python files here...
)]
#[case(
"fail-empty-glob-outside-search-mode-sorted",
"fail-no-files-outside-search-mode-sorted",
None,
&[
"--sorted",
"--fail-empty-glob",
"--fail-no-files",
"--files",
"**/*.there-is-no-such-suffix",
r".",
Expand Down Expand Up @@ -588,21 +588,21 @@ Heizoelrueckstossabdaempfung.
None,
)]
#[case(
"fail-empty-glob-in-search-mode-multithreaded",
"fail-no-files-in-search-mode-multithreaded",
None,
&[
"--fail-empty-glob",
"--fail-no-files",
"--python",
"strings",
r".",
],
Some(Path::new("tests/langs/go")), // No Python files here...
)]
#[case(
"fail-empty-glob-outside-search-mode-multithreaded",
"fail-no-files-outside-search-mode-multithreaded",
None,
&[
"--fail-empty-glob",
"--fail-no-files",
"--files",
"**/*.there-is-no-such-suffix",
r".",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
- "Error: No files found"
---
args:
- "--fail-empty-glob"
- "--fail-no-files"
- "--python"
- strings
- "."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
---
args:
- "--sorted"
- "--fail-empty-glob"
- "--fail-no-files"
- "--python"
- strings
- "."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
- "Error: No files found"
---
args:
- "--fail-empty-glob"
- "--fail-no-files"
- "--files"
- "**/*.there-is-no-such-suffix"
- "."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
---
args:
- "--sorted"
- "--fail-empty-glob"
- "--fail-no-files"
- "--files"
- "**/*.there-is-no-such-suffix"
- "."
Expand Down

0 comments on commit ff615cc

Please sign in to comment.