Conversation
This commit adds a new 'search' command that allows users to find tasks by searching for keywords in task titles. The search is case-insensitive and matches partial strings. Usage: ./tasks search "keyword" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR adds a new ChangesTask Search Feature
Sequence DiagramsequenceDiagram
participant User
participant searchCmd
participant store
participant Output
User->>searchCmd: ./tasks search "keyword"
searchCmd->>store: Load()
store-->>searchCmd: tasks list
searchCmd->>searchCmd: Filter by keyword
searchCmd->>Output: Print matching tasks
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
|
Tip For best results, initiate chat on the files or code changes. Hi |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/search.go`:
- Around line 14-17: The command currently allows multiple args (Args:
cobra.MinimumNArgs(1)) but only uses args[0] in the RunE closure (variable
keyword), causing extra terms to be ignored; update RunE in cmd/search.go to
combine all args into a single search string (e.g., keyword :=
strings.ToLower(strings.Join(args, " "))) so multi-word searches like "./tasks
search foo bar" use both terms, or alternatively change the Args validator to
cobra.ExactArgs(1) if you want to enforce a single-term search—apply the change
to the RunE closure (where keyword is defined) and keep logging/validation
consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| Args: cobra.MinimumNArgs(1), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| keyword := strings.ToLower(args[0]) | ||
|
|
There was a problem hiding this comment.
Prevent silently ignoring extra search terms.
Line 14 accepts multiple args, but Line 16 only searches args[0], so ./tasks search foo bar drops bar without feedback.
💡 Proposed fix
RunE: func(cmd *cobra.Command, args []string) error {
- keyword := strings.ToLower(args[0])
+ if len(args) > 1 {
+ return fmt.Errorf("search expects a single keyword; wrap multi-word phrases in quotes")
+ }
+ keyword := strings.TrimSpace(args[0])
+ if keyword == "" {
+ return fmt.Errorf("keyword cannot be empty")
+ }
+ keyword = strings.ToLower(keyword)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Args: cobra.MinimumNArgs(1), | |
| RunE: func(cmd *cobra.Command, args []string) error { | |
| keyword := strings.ToLower(args[0]) | |
| Args: cobra.MinimumNArgs(1), | |
| RunE: func(cmd *cobra.Command, args []string) error { | |
| if len(args) > 1 { | |
| return fmt.Errorf("search expects a single keyword; wrap multi-word phrases in quotes") | |
| } | |
| keyword := strings.TrimSpace(args[0]) | |
| if keyword == "" { | |
| return fmt.Errorf("keyword cannot be empty") | |
| } | |
| keyword = strings.ToLower(keyword) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@cmd/search.go` around lines 14 - 17, The command currently allows multiple
args (Args: cobra.MinimumNArgs(1)) but only uses args[0] in the RunE closure
(variable keyword), causing extra terms to be ignored; update RunE in
cmd/search.go to combine all args into a single search string (e.g., keyword :=
strings.ToLower(strings.Join(args, " "))) so multi-word searches like "./tasks
search foo bar" use both terms, or alternatively change the Args validator to
cobra.ExactArgs(1) if you want to enforce a single-term search—apply the change
to the RunE closure (where keyword is defined) and keep logging/validation
consistent.
This commit adds a new 'search' command that allows users to find tasks by searching for keywords in task titles. The search is case-insensitive and matches partial strings.
Usage: ./tasks search "keyword"
Summary by CodeRabbit
New Features
searchcommand to find tasks by keyword. Results display matching task titles with completion status indicators and task identifiers. A "no tasks found" message is shown when the search yields no results.Documentation
searchCLI command with practical usage examples and instructions.