Skip to content

feat: bookmarks search#968

Open
dhimanAbhi wants to merge 2 commits into
clidey:mainfrom
dhimanAbhi:feat/bookmarks-search
Open

feat: bookmarks search#968
dhimanAbhi wants to merge 2 commits into
clidey:mainfrom
dhimanAbhi:feat/bookmarks-search

Conversation

@dhimanAbhi
Copy link
Copy Markdown
Contributor

Related Issue

Closes #959

What does this PR do?

Adds a new whodb-cli bookmarks search [pattern] command to filter saved bookmarks by name and SQL query text.

Why?

Currently, users must scan all bookmarks manually using list. This becomes inefficient as the number of bookmarks grows. This feature enables quick lookup by name or query content.

How it works

The user can use this command by passing an arguement of a bookmark's name or query. The command filters from existing bookmarks and returns results.

Usage

whodb-cli bookmarks search pattern

How was this tested?

Manual testing:

./whodb-cli bookmarks list 
name    query
get-str-table   SELECT * FROM strtab
get-rec SELECT * FROM strtab
get-age SELECT age FROM strtab
get-age-gt-ten  SELECT age FROM strtab
whodb-cli bookmarks search age --format json
[
  {
    "name": "get-age",
    "query": "SELECT age FROM strtab"
  },
  {
    "name": "get-age-gt-ten",
    "query": "SELECT age FROM strtab"
  }
]
whodb-cli bookmarks search SELECT
name    query
get-str-table   SELECT * FROM strtab
get-rec SELECT * FROM strtab
get-age SELECT age FROM strtab
get-age-gt-ten  SELECT age FROM strtab
whodb-cli bookmarks search SELECT --format json
[
  {
    "name": "get-str-table",
    "query": "SELECT * FROM strtab"
  },
  {
    "name": "get-rec",
    "query": "SELECT * FROM strtab"
  },
  {
    "name": "get-age",
    "query": "SELECT age FROM strtab"
  },
  {
    "name": "get-age-gt-ten",
    "query": "SELECT age FROM strtab"
  }
]

./whodb-cli bookmarks search sdfds --format json
[]

Screenshots / recordings

Checklist

  • I have read the Contributing Guidelines
  • I discussed this change in an issue before starting work
  • My PR description is written in my own words and accurately describes my changes
  • I have tested my changes locally
  • I have not included build artifacts or unrelated changes

@modelorona
Copy link
Copy Markdown
Collaborator

modelorona commented May 8, 2026

@dhimanAbhi this looks like a duplicate of #973, is that intended or did you mean to only open that one?

@dhimanAbhi dhimanAbhi changed the title Feat/bookmarks search feat: bookmarks search May 9, 2026
Copy link
Copy Markdown

@renezander030 renezander030 left a comment

Choose a reason for hiding this comment

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

Hi @dhimanAbhi,

Three things from reading the diff:

  1. Stray backtick in the Short description: Short: "Search saved bookmarks\",— the trailing backtick will show up in--help` output.

  2. The acceptance criteria on #959 calls for tests covering name match, query match, no match, and JSON output. The current diff doesn't add any. The other CLI commands in cli/cmd/ have programmatic tests in programmatic_commands_test.go that you could mirror.

  3. strings.ReplaceAll(value.Query, "\n", " ") is applied to the row before passing to WriteQueryResult, which means the JSON output also returns the newlines-collapsed query rather than the original SQL. Worth keeping the original value.Query in the row and letting the table renderer be the one that flattens whitespace for display only.

Also re modelorona's comment about #973 being a duplicate — if that one is intended as the canonical PR it might be worth closing one of them to unblock the review.

Thanks for the work on this.

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.

[FR] - Add bookmark search to the CLI

3 participants