Skip to content

Add search subcommand with tag, date, and project filters#17

Open
Intina47 wants to merge 1 commit intomainfrom
mamba/add-filters-to-jot-search-command
Open

Add search subcommand with tag, date, and project filters#17
Intina47 wants to merge 1 commit intomainfrom
mamba/add-filters-to-jot-search-command

Conversation

@Intina47
Copy link
Owner

Motivation

  • Provide a way to slice and find notebook entries by tag, date range, and project/repo context from the CLI.
  • Support combinable filters so users can run searches like jot search "incident" --tag prod --since 2024-01-01 --project myrepo.

Description

  • Add a search subcommand and flag parsing in main.go with repeatable --tag, --since, --until, and --project flags and a runJotSearch entrypoint.
  • Implement entry parsing (parseEntry) plus helpers for date-only comparison (dateOnly, parseDateInput), tag/project extraction (tagRegex, projectRegex, entryHasTags, entryHasProject), and normalization (normalizeSlice).
  • Implement the main search engine jotSearch which applies text query, tag, project, and date-range filters combinatorially and streams matched lines to the writer.
  • Document the new jot search usage and conventions in README.md and add unit tests covering tag, date-range, and project filtering in main_test.go.

Testing

  • Ran go test ./... and the test suite passed (all tests succeeded).
  • Added unit tests TestJotSearchFiltersByTag, TestJotSearchFiltersByDate, and TestJotSearchFiltersByProject which exercise the new filtering logic and passed during the test run.

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +186 to +190
if err := flags.Parse(args); err != nil {
return err
}

query := strings.TrimSpace(strings.Join(flags.Args(), " "))

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant