Add search subcommand with tag, date, and project filters#17
Add search subcommand with tag, date, and project filters#17
search subcommand with tag, date, and project filters#17Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42472a8526
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if err := flags.Parse(args); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| query := strings.TrimSpace(strings.Join(flags.Args(), " ")) |
There was a problem hiding this comment.
Parse flags before query or filters are ignored
Go’s flag.FlagSet.Parse stops at the first non-flag argument, so with the documented usage jot search "incident" --tag prod the parser will stop at incident and leave --tag prod in flags.Args(). That means opts.tags/since/until/project stay empty and the query becomes incident --tag prod, silently disabling filtering. This makes the new filters unusable unless users put all flags before the query (or use --). Consider supporting interspersed flags (e.g., custom parsing or pflag) or enforcing/communicating a flags-before-query convention.
Useful? React with 👍 / 👎.
Motivation
jot search "incident" --tag prod --since 2024-01-01 --project myrepo.Description
searchsubcommand and flag parsing inmain.gowith repeatable--tag,--since,--until, and--projectflags and arunJotSearchentrypoint.parseEntry) plus helpers for date-only comparison (dateOnly,parseDateInput), tag/project extraction (tagRegex,projectRegex,entryHasTags,entryHasProject), and normalization (normalizeSlice).jotSearchwhich applies text query, tag, project, and date-range filters combinatorially and streams matched lines to the writer.jot searchusage and conventions inREADME.mdand add unit tests covering tag, date-range, and project filtering inmain_test.go.Testing
go test ./...and the test suite passed (all tests succeeded).TestJotSearchFiltersByTag,TestJotSearchFiltersByDate, andTestJotSearchFiltersByProjectwhich exercise the new filtering logic and passed during the test run.Codex Task