fix: improve command robustness and flag support#14
fix: improve command robustness and flag support#14pszymkowiak merged 1 commit intortk-ai:masterfrom
Conversation
## Fixes ### Lint crash handling - Add graceful error handling for linter crashes (SIGABRT, OOM) - Display warning message when process terminates abnormally - Show first 5 lines of stderr for debugging context ### Grep command - Add --type/-t flag for file type filtering (e.g., --type ts, --type py) - Passes --type argument to ripgrep for efficient filtering ### Find command - Add --type/-t flag for file/directory filtering - Default: "f" (files only) - Options: "f" (file), "d" (directory) ## Testing - ✅ cargo check passes - ✅ cargo build --release succeeds - ✅ rtk grep --help shows --file-type flag - ✅ rtk find --help shows --file-type flag with default ## Breaking Changes None - all changes are backwards compatible additions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds file type filtering flags to the grep and find commands, and improves error handling for linter crashes.
Changes:
- Added
--file-typeflag to grep and find commands for filtering by file/directory type - Improved lint command to detect and report signal-based process termination (e.g., SIGABRT, OOM)
- Enhanced robustness when external tools crash or are terminated abnormally
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/main.rs | Added file_type parameter to Find and Grep command structs with appropriate defaults |
| src/lint_cmd.rs | Added signal termination detection to provide user-friendly warning messages when linters crash |
| src/grep_cmd.rs | Updated to accept and pass file_type parameter to ripgrep's --type flag |
| src/find_cmd.rs | Updated to accept and pass file_type parameter to fd/find's --type flag |
Comments suppressed due to low confidence (1)
src/grep_cmd.rs:33
- The file_type parameter is only applied to the ripgrep command but not to the fallback grep command. When ripgrep is unavailable and grep is used instead, the file type filtering will be silently ignored. Consider either: (1) documenting that file_type filtering requires ripgrep, (2) implementing file type filtering for the grep fallback (though standard grep doesn't have built-in type filtering), or (3) returning an error if file_type is specified but ripgrep is unavailable.
.or_else(|_| {
Command::new("grep")
.args(["-rn", pattern, path])
.output()
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub fn run(pattern: &str, path: &str, max_results: usize, file_type: &str, verbose: u8) -> Result<()> { | ||
| if verbose > 0 { | ||
| eprintln!("find: {} in {}", pattern, path); | ||
| } | ||
|
|
||
| let output = Command::new("fd") | ||
| .args([pattern, path, "--type", "f"]) | ||
| .args([pattern, path, "--type", file_type]) |
There was a problem hiding this comment.
The new file_type parameter is not covered by any tests. Since this codebase has comprehensive test coverage (as seen in grep_cmd.rs and other files), consider adding tests to verify the file_type parameter is correctly passed to both fd and find commands.
| if let Some(ft) = file_type { | ||
| rg_cmd.arg("--type").arg(ft); | ||
| } |
There was a problem hiding this comment.
The new file_type parameter is not covered by any tests. Since this codebase has comprehensive test coverage (as seen in the existing tests at the end of this file), consider adding tests to verify the file_type parameter is correctly passed to ripgrep when specified.
| #[arg(short = 't', long, default_value = "f")] | ||
| file_type: String, |
There was a problem hiding this comment.
The PR description claims this adds a '--type' flag, but the actual flag name will be '--file-type' (with short form '-t'). This is because clap converts the field name 'file_type' to '--file-type' with kebab-case. Consider either updating the PR description to reflect the actual flag name, or explicitly setting the flag name using '#[arg(short = 't', long = "type")]' to match the description.
| #[arg(short = 't', long)] | ||
| file_type: Option<String>, |
There was a problem hiding this comment.
The PR description claims this adds a '--type' flag, but the actual flag name will be '--file-type' (with short form '-t'). This is because clap converts the field name 'file_type' to '--file-type' with kebab-case. Consider either updating the PR description to reflect the actual flag name, or explicitly setting the flag name using '#[arg(short = 't', long = "type")]' to match the description.
Updates documentation to reflect all features added in recent PRs: **Version Updates** - Update installation commands to v0.3.1 (DEB/RPM packages) **New Sections** - Add Global Flags section (-u/--ultra-compact, -v/--verbose) - Add JavaScript/TypeScript Stack section (10 new commands) **New Commands Documented** - Files: `rtk smart` (heuristic code summary) - Commands: `rtk gh` (GitHub CLI), `rtk wget`, `rtk config` - Data: `rtk gain --quota` and `--tier` flags - Containers: `rtk kubectl services` - JS/TS Stack: lint, tsc, next, prettier, vitest, playwright, prisma **Features Coverage** This update documents functionality from: - PR rtk-ai#5: Git argument parsing improvements - PR rtk-ai#6: pnpm support - PR rtk-ai#9: Modern JavaScript/TypeScript stack support - PR rtk-ai#10: GitHub CLI integration - PR rtk-ai#11: Quota analysis features - PR rtk-ai#14: Additional command improvements All commands documented are available in v0.3.1. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates documentation to reflect all features added in recent PRs: **Version Updates** - Update installation commands to v0.3.1 (DEB/RPM packages) **New Sections** - Add Global Flags section (-u/--ultra-compact, -v/--verbose) - Add JavaScript/TypeScript Stack section (10 new commands) **New Commands Documented** - Files: `rtk smart` (heuristic code summary) - Commands: `rtk gh` (GitHub CLI), `rtk wget`, `rtk config` - Data: `rtk gain --quota` and `--tier` flags - Containers: `rtk kubectl services` - JS/TS Stack: lint, tsc, next, prettier, vitest, playwright, prisma **Features Coverage** This update documents functionality from: - PR rtk-ai#5: Git argument parsing improvements - PR rtk-ai#6: pnpm support - PR rtk-ai#9: Modern JavaScript/TypeScript stack support - PR rtk-ai#10: GitHub CLI integration - PR rtk-ai#11: Quota analysis features - PR rtk-ai#14: Additional command improvements All commands documented are available in v0.3.1. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…d-bugs fix: improve command robustness and flag support
Updates documentation to reflect all features added in recent PRs: **Version Updates** - Update installation commands to v0.3.1 (DEB/RPM packages) **New Sections** - Add Global Flags section (-u/--ultra-compact, -v/--verbose) - Add JavaScript/TypeScript Stack section (10 new commands) **New Commands Documented** - Files: `rtk smart` (heuristic code summary) - Commands: `rtk gh` (GitHub CLI), `rtk wget`, `rtk config` - Data: `rtk gain --quota` and `--tier` flags - Containers: `rtk kubectl services` - JS/TS Stack: lint, tsc, next, prettier, vitest, playwright, prisma **Features Coverage** This update documents functionality from: - PR rtk-ai#5: Git argument parsing improvements - PR rtk-ai#6: pnpm support - PR rtk-ai#9: Modern JavaScript/TypeScript stack support - PR rtk-ai#10: GitHub CLI integration - PR rtk-ai#11: Quota analysis features - PR rtk-ai#14: Additional command improvements All commands documented are available in v0.3.1. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix misleading correctable count comment in rubocop_cmd.rs to explain the 0-value ambiguity (absent field vs genuinely zero) (issue rtk-ai#8) - Update compact_minitest_failure doc to describe full behavior including message line context (issue rtk-ai#14) - Add JSON-parse-failure fallback mention to rspec_cmd.rs and rubocop_cmd.rs module-level docs (issue rtk-ai#15) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
--type ts,--type py)f)Motivation
Testing on Méthode Aristote revealed:
--typeflag caused parse errors in grep/findChanges
src/lint_cmd.rs
src/grep_cmd.rs + src/main.rs
--type/-toptional flag for file type filtering--typefor efficient filteringrtk grep "export" --type tssrc/find_cmd.rs + src/main.rs
--type/-tflag with default value "f" (files)rtk find "*.tsx" --type fTesting
cargo checkpassescargo build --releasesucceedsrtk grep --helpshows new--file-typeflagrtk find --helpshows new--file-typeflag with defaultBackwards Compatibility
✅ No breaking changes
Note
The "vitest routing bug" was user error (calling
rtk test tests/unit/libinstead ofrtk vitest run). No code changes needed.🤖 Generated with Claude Code