Skip to content

Add search command to filter tasks by keyword#2

Open
akarol wants to merge 1 commit into
mainfrom
test
Open

Add search command to filter tasks by keyword#2
akarol wants to merge 1 commit into
mainfrom
test

Conversation

@akarol
Copy link
Copy Markdown
Owner

@akarol akarol commented May 21, 2026

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

    • Added a search command 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

    • Updated README to document the new search CLI command with practical usage examples and instructions.

Review Change Stack

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

This PR adds a new search subcommand to the task CLI tool that allows users to search tasks by keyword. The command loads tasks from storage, filters them by case-insensitive substring matching, and displays matching entries with their done status and IDs. The README is updated to document this new functionality.

Changes

Task Search Feature

Layer / File(s) Summary
Search command implementation and registration
cmd/search.go
The search command accepts a keyword argument, loads tasks via store.Load(), filters by case-insensitive title match, and prints matching tasks with checkbox-style done indicators and IDs. Imports fmt, strings, store, and cobra; command is registered with rootCmd in init().
Search command documentation
README.md
The Commands section adds an example showing how to search tasks by keyword: ./tasks search "grocery".

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

A rabbit hops through task lists long,
With search command now strong and keen,
Filter by keyword, find what's wrong,
The simplest search you've ever seen! 🐰✨

🚥 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 summarizes the main change: adding a search command that filters tasks by keyword, which matches the core functionality described in the raw summary and PR objectives.
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 test

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.

@akarol
Copy link
Copy Markdown
Owner Author

akarol commented May 21, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Tip

For best results, initiate chat on the files or code changes.

Hi @akarol! 👋 How can I help you today? Whether you'd like me to review the PR, answer questions about the code changes, or anything else — just let me know!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7345e65a-e293-4690-a7ac-36c86d18bed7

📥 Commits

Reviewing files that changed from the base of the PR and between 9e9761d and 6d3706b.

📒 Files selected for processing (2)
  • README.md
  • cmd/search.go

Comment thread cmd/search.go
Comment on lines +14 to +17
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
keyword := strings.ToLower(args[0])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
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.

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