Skip to content

feat: shorthand search — grepturbo <pattern> without search subcommand#21

Merged
yanurag-dev merged 1 commit into
mainfrom
feat/shorthand-search
May 23, 2026
Merged

feat: shorthand search — grepturbo <pattern> without search subcommand#21
yanurag-dev merged 1 commit into
mainfrom
feat/shorthand-search

Conversation

@yanurag-dev

@yanurag-dev yanurag-dev commented May 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • grepturbo <pattern> now works as a shorthand for grepturbo search <pattern>
  • Both quoted (grepturbo "foo") and unquoted (grepturbo foo) forms work
  • grepturbo search <pattern> continues to work unchanged

How it works

Before cobra parses args, os.Args is inspected: if the first argument isn't a known subcommand (build, search, init, help, completion) or a flag, search is injected automatically.

Test plan

  • grepturbo <pattern> returns same results as grepturbo search <pattern>
  • grepturbo search <pattern> still works
  • grepturbo build and grepturbo init unaffected
  • Flags like grepturbo -i .grepturbo <pattern> still work

Summary by CodeRabbit

  • New Features
    • Streamlined search command: grepturbo <pattern> now works as a shorthand for grepturbo search <pattern>, providing a faster way to perform searches while maintaining full backward compatibility with explicit subcommands.

Review Change Stack

…ttern>

Patterns that don't match a known subcommand name are automatically routed
to the search command, so both `grepturbo "foo"` and `grepturbo foo` work.
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR modifies the grepturbo CLI entry point to automatically detect and handle implicit search patterns. When a user provides a search pattern without an explicit subcommand, the program rewrites os.Args to insert the search subcommand, enabling the shorthand grepturbo <pattern> syntax.

Changes

Implicit search subcommand injection

Layer / File(s) Summary
Implicit search subcommand injection
cmd/grepturbo/main.go
main() detects when the first argument is a plain search pattern (non-empty, not starting with -, and not a known subcommand) and rewrites os.Args to inject the search subcommand before it.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through arguments with glee,
Injecting search where patterns should be,
No more explicit words to type with care,
Just pattern and magic—a shorthand so fair! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature being added: shorthand search syntax allowing users to run grepturbo with a pattern directly, without explicitly specifying the search subcommand.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/shorthand-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yanurag-dev
yanurag-dev merged commit d763ffc into main May 23, 2026
1 of 2 checks passed
@yanurag-dev
yanurag-dev deleted the feat/shorthand-search branch May 23, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant