Skip to content

feat(notes): add --latest to notes get for ambiguous slugs#730

Merged
tlongwell-block merged 1 commit into
mainfrom
eva/notes-latest-flag
May 23, 2026
Merged

feat(notes): add --latest to notes get for ambiguous slugs#730
tlongwell-block merged 1 commit into
mainfrom
eva/notes-latest-flag

Conversation

@tlongwell-block
Copy link
Copy Markdown
Collaborator

What

Adds --latest to sprout notes get. On a bare --name that matches notes from multiple authors, the CLI errors out (a slug isn't globally unique — notes are keyed by (kind, author, slug)). --latest opts into picking the most recently updated candidate instead.

sprout notes get --name skills-index --latest    # → newest matching note

Why

Enables wiki-style "just give me the current one" reads against a shared slug without forcing the caller to know an author pubkey. The strict-by-default behavior stays — --latest is opt-in.

Design

  • --latest conflicts with --author and --naddr (both already pin a single note); rejected with a clear usage error.
  • The ambiguity error now also points at --latest.
  • Selection reuses the existing sort_snapshots_newest_first then takes the head — no new ranking logic.
  • Flag validation extracted to a pure validate_get_args(naddr, name, author, latest) helper so the full combination matrix is unit-tested without a relay.

Testing

  • cargo test -p sprout-cli — 107 passed (4 new validate_get_args cases).
  • cargo clippy -p sprout-cli --all-targets — clean.
  • End-to-end against the live relay: --latest returns the newest skills-index; bare --name still errors (now mentioning --latest); --latest --author and --latest --naddr both rejected.

A bare `--name` with hits from multiple authors errors out, since a slug
isn't unique — notes are keyed by (kind, author, slug). That's the right
default, but it blocks wiki-style "just give me the current one" reads.

`--latest` opts into picking the most recently updated candidate instead
of erroring. Default stays strict; `--latest` conflicts with `--author`
and `--naddr` (both already pin a single note). The ambiguity error now
also points at `--latest`.

Flag validation is extracted to a pure `validate_get_args` helper so the
full matrix is unit-tested without a relay.

Signed-off-by: Tyler Longwell <109685178+tlongwell-block@users.noreply.github.com>
@tlongwell-block tlongwell-block requested a review from a team as a code owner May 23, 2026 01:06
@tlongwell-block tlongwell-block merged commit 2a8b765 into main May 23, 2026
16 checks passed
@tlongwell-block tlongwell-block deleted the eva/notes-latest-flag branch May 23, 2026 01:16
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