Skip to content

feat(set): add --promote flag to update event timestamp on set - #25

Merged
Nadim147c merged 1 commit into
Nadim147c:mainfrom
WayneKent:feat/set-promote
Aug 1, 2026
Merged

Nadim147c merged 1 commit into
Nadim147c:mainfrom
WayneKent:feat/set-promote

Conversation

@WayneKent

Copy link
Copy Markdown
Contributor

Summary

Add a --promote flag to yankd set that updates the event timestamp to now when setting clipboard content, moving the item to the top of the list.

Changes

  • New file internal/db/update.go: UpdateEventTime DB method to update an event's timestamp
  • internal/ipc/set.go: SetEvent now accepts a promote bool parameter; when ?promote=true query param is present, the event time is updated after setting to clipboard
  • cmd/set.go: yankd set gains --promote / -p flag, plus Long description and Example
  • internal/ipc/README.md: Document the ?promote=true query parameter

Usage

# CLI
yankd set --promote <uuid>
yankd set -p <uuid>

# HTTP API (for Quickshell or other frontends)
curl -X POST --unix-socket /run/user/1000/yankd.sock "http://unix/set/<uuid>?promote=true"

Without the flag/param, behavior is unchanged.

Comment thread cmd/set.go Outdated
Comment on lines +20 to +26
Long: `Set clipboard content from history by event ID.

With --promote, the event timestamp is updated to now,
moving it to the top of the list on next load.`,
Example: ` yankd set 019fb267-e9b8-700d-a100-643a7e8bf651
yankd set --promote 019fb267-e9b8-700d-a100-643a7e8bf651
yankd set -p 019fb267-e9b8-700d-a100-643a7e8bf651`,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
Long: `Set clipboard content from history by event ID.
With --promote, the event timestamp is updated to now,
moving it to the top of the list on next load.`,
Example: ` yankd set 019fb267-e9b8-700d-a100-643a7e8bf651
yankd set --promote 019fb267-e9b8-700d-a100-643a7e8bf651
yankd set -p 019fb267-e9b8-700d-a100-643a7e8bf651`,
Example: `
# Restore clipboard of given id
yankd set 019fb267-e9b8-700d-a100-643a7e8bf651
# Restore clipboard of given id and update timestamp
yankd set --promote 019fb267-e9b8-700d-a100-643a7e8bf651
`,

I prefer this style.

Comment thread cmd/set.go Outdated
}

res, err := ipc.SetEvent(cmd.Context(), id)
promote, _ := cmd.Flags().GetBool("promote")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please, use viper.GetBool("promote")!

@Nadim147c

Copy link
Copy Markdown
Owner

LGTM! Please run a gofumpt to make github action happy.

- Add UpdateEventTime DB method to update an event timestamp
- Add --promote (-p) flag to `yankd set` CLI command
- Add Long description and Example for the set command
- Update ipc/README.md with promote query param docs
- When ?promote=true is present, update the event time to now
  after setting clipboard content, promoting it to the top
@WayneKent

Copy link
Copy Markdown
Contributor Author

Done, ran gofumpt.

@Nadim147c
Nadim147c merged commit 2810678 into Nadim147c:main Aug 1, 2026
1 check passed
@WayneKent
WayneKent deleted the feat/set-promote branch August 1, 2026 15:54
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.

2 participants