add fixed_string param to ripgrep tool
This commit is contained in:
parent
60a6707107
commit
3e68dd3fa6
|
|
@ -79,6 +79,7 @@ def ripgrep_search(
|
||||||
include_hidden: bool = False,
|
include_hidden: bool = False,
|
||||||
follow_links: bool = False,
|
follow_links: bool = False,
|
||||||
exclude_dirs: List[str] = None,
|
exclude_dirs: List[str] = None,
|
||||||
|
fixed_string: bool = False,
|
||||||
) -> Dict[str, Union[str, int, bool]]:
|
) -> Dict[str, Union[str, int, bool]]:
|
||||||
"""Execute a ripgrep (rg) search with formatting and common options.
|
"""Execute a ripgrep (rg) search with formatting and common options.
|
||||||
|
|
||||||
|
|
@ -93,6 +94,7 @@ def ripgrep_search(
|
||||||
include_hidden: Whether to search hidden files and directories (default: False)
|
include_hidden: Whether to search hidden files and directories (default: False)
|
||||||
follow_links: Whether to follow symbolic links (default: False)
|
follow_links: Whether to follow symbolic links (default: False)
|
||||||
exclude_dirs: Additional directories to exclude (combines with defaults)
|
exclude_dirs: Additional directories to exclude (combines with defaults)
|
||||||
|
fixed_string: Whether to treat pattern as a literal string instead of regex (default: False)
|
||||||
"""
|
"""
|
||||||
# Build rg command with options
|
# Build rg command with options
|
||||||
cmd = ["rg", "--color", "always"]
|
cmd = ["rg", "--color", "always"]
|
||||||
|
|
@ -122,6 +124,10 @@ def ripgrep_search(
|
||||||
for dir in exclusions:
|
for dir in exclusions:
|
||||||
cmd.extend(["--glob", f"!{dir}"])
|
cmd.extend(["--glob", f"!{dir}"])
|
||||||
|
|
||||||
|
# Add fixed string flag if specified
|
||||||
|
if fixed_string:
|
||||||
|
cmd.append("-F")
|
||||||
|
|
||||||
# Add the search pattern
|
# Add the search pattern
|
||||||
cmd.append(pattern)
|
cmd.append(pattern)
|
||||||
|
|
||||||
|
|
@ -134,6 +140,7 @@ def ripgrep_search(
|
||||||
f"**Pattern**: `{pattern}`",
|
f"**Pattern**: `{pattern}`",
|
||||||
f"**Case Sensitive**: {case_sensitive}",
|
f"**Case Sensitive**: {case_sensitive}",
|
||||||
f"**File Type**: {file_type or 'all'}",
|
f"**File Type**: {file_type or 'all'}",
|
||||||
|
f"**Fixed String**: {fixed_string}",
|
||||||
]
|
]
|
||||||
if before_context_lines is not None:
|
if before_context_lines is not None:
|
||||||
params.append(f"**Before Context Lines**: {before_context_lines}")
|
params.append(f"**Before Context Lines**: {before_context_lines}")
|
||||||
|
|
@ -173,4 +180,4 @@ def ripgrep_search(
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = str(e)
|
error_msg = str(e)
|
||||||
console.print(Panel(error_msg, title="❌ Error", border_style="red"))
|
console.print(Panel(error_msg, title="❌ Error", border_style="red"))
|
||||||
return {"output": error_msg, "return_code": 1, "success": False}
|
return {"output": error_msg, "return_code": 1, "success": False}
|
||||||
Loading…
Reference in New Issue