-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add case_sensitive, smart_case, no_ignore, hidden, and json options #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ions Add support for commonly used ripgrep flags: - case_sensitive (bool): Control case sensitivity (-s/-i flags) - smart_case (bool): Enable smart case matching (-S flag) - no_ignore (bool): Disable .gitignore/.ignore handling (--no-ignore flag) - hidden (bool): Search hidden files and directories (--hidden flag) - json (bool): Output results in JSON Lines format (--json flag) Updated: - src/ripgrep_core.rs: Added fields to PyArgs, conversion logic, and JSON search impl - src/ripgrep_core/hiargs.rs: Made printer_json public (1 line change) - python_ripgrep/__init__.pyi: Updated type stubs - README.md: Documented new features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds five new search options to the python-ripgrep library: case_sensitive, smart_case, no_ignore, hidden, and json. These options provide more control over how ripgrep searches files and outputs results, bringing the Python wrapper closer to feature parity with the ripgrep CLI tool.
Key changes:
- Added support for case sensitivity control (
case_sensitive,smart_case) - Added ignore file handling control (
no_ignore) - Added hidden files search support (
hidden) - Added JSON output format support (
json)
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ripgrep_core.rs | Adds the five new parameters to PyArgs struct, search/files function signatures, and implements case sensitivity, ignore handling, hidden files, and JSON output logic |
| src/ripgrep_core/hiargs.rs | Changes visibility of printer_json method from private to pub(crate) to enable JSON output support |
| python_ripgrep/init.pyi | Updates type stubs to include the five new optional boolean parameters for both search and files functions |
| README.md | Documents the newly implemented flags and removes them from the unimplemented list |
| Cargo.lock | Updates Cargo.lock version format and package version to 0.1.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else if let Some(false) = py_args.case_sensitive { | ||
| low_args.case = lowargs::CaseMode::Insensitive; | ||
| } else if let Some(true) = py_args.case_sensitive { | ||
| low_args.case = lowargs::CaseMode::Sensitive; |
Copilot
AI
Jan 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case sensitivity handling logic has a priority issue. When both smart_case and case_sensitive are provided by the user, the current logic will allow case_sensitive to override smart_case because the conditions are checked sequentially with else if statements but evaluate them independently.
For example, if a user passes smart_case=True and case_sensitive=False, the code will first set CaseMode::Smart on line 225, but then immediately override it with CaseMode::Insensitive on line 227.
The logic should prioritize smart_case over case_sensitive when both are set. Consider restructuring to check smart_case first and only evaluate case_sensitive if smart_case is not set to true.
| } else if let Some(false) = py_args.case_sensitive { | |
| low_args.case = lowargs::CaseMode::Insensitive; | |
| } else if let Some(true) = py_args.case_sensitive { | |
| low_args.case = lowargs::CaseMode::Sensitive; | |
| } else if let Some(case_sensitive) = py_args.case_sensitive { | |
| low_args.case = if case_sensitive { | |
| lowargs::CaseMode::Sensitive | |
| } else { | |
| lowargs::CaseMode::Insensitive | |
| }; |
| json, | ||
| }; | ||
|
|
||
| let args_result = pyargs_to_hiargs(&py_args, lowargs::Mode::Files); |
Copilot
AI
Jan 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The json parameter is accepted by the py_files function but is never used. The function always passes lowargs::Mode::Files to pyargs_to_hiargs regardless of the json parameter value. This could be confusing to API users who might expect JSON output when they pass json=True.
If JSON mode is not supported for the files listing operation (which appears to be the case since py_files_impl simply returns file paths), consider either removing the json parameter from this function's signature or adding validation to return an error when json=True is passed to clarify that this option is not supported for file listing.
Would you be willing to include some more options for this? Would save me the work to fork and publish myself :)