Skip to content

feat(cli): repeatable surface flags + id-leading-separator fix#169

Merged
benvinegar merged 2 commits into
mainfrom
cli-repeatable-surface-flags
Jun 27, 2026
Merged

feat(cli): repeatable surface flags + id-leading-separator fix#169
benvinegar merged 2 commits into
mainfrom
cli-repeatable-surface-flags

Conversation

@benvinegar

Copy link
Copy Markdown
Member

What

Two changes, one PR:

1. Repeatable surface flags (closes #151)

sideshow publish and sideshow surface add now accept repeated surface flags to add several surfaces of the same kind, in command-line order:

sideshow publish card.html --diff a.patch --code c.ts --diff b.patch
# → [html, diff, code, diff]

Previously parseArgs silently kept only the last value of a repeated non-multiple flag. All seven surface flags (--md, --mermaid, --diff, --terminal, --json, --code, --image) are now multiple: true in both commands. Shared buildSurface/surfacesFromFlags helpers ensure both commands construct surfaces identically. surface add POSTs each surface separately so --before/--after positioning applies per surface.

2. Fix: ids starting with - or _ no longer break CLI

newId emits base64url ids where +- and /_, so ~1/64 of ids started with a separator. parseArgs strict mode treated them as unknown options (Unknown option '-6' for an id like -6K4AJsKD4M), breaking every id-positional command (update, show, surface add/remove/edit/move).

Generator fix: newId swaps a leading separator for an alphanumeric — new ids are always CLI-safe.

Parser fix: parse() swaps id-shaped -/_-prefixed tokens for a sentinel before parseArgs sees them, then restores them in positionals, tokens, and option values — rescuing already-stored bad ids.

Test plan

  • npm test — 381 pass, 0 fail (3 consecutive runs)
  • npm run typecheck — clean
  • npm run lint — clean
  • npm run format:check — clean
  • New tests: publish repeats a surface flag to add several of the same kind, in order and surface add repeats a flag to append several of the same kind, in order
  • Flaky test failure (caused by leading-- ids under concurrent test load) is gone

newId could emit ids starting with - or _ (~1/64 each, from base64url
substitution). parseArgs strict mode treated them as unknown options,
breaking every id-positional command (update, show, surface add/remove/
edit/move).

Generator fix: newId swaps a leading separator for an alphanumeric.
Parser fix: parse() swaps id-shaped -/_-prefixed tokens for a sentinel
before parseArgs sees them, then restores them in positionals, tokens,
and option values — rescuing already-stored bad ids.
All seven surface flags (--md, --mermaid, --diff, --terminal, --json,
--code, --image) are now multiple: true in both publish and surface add,
so repeated flags add multiple surfaces of the same kind in command-line
order: --diff a --code c --diff b → [html, diff, code, diff].

Previously parseArgs silently kept only the last value of a repeated
non-multiple flag. Shared buildSurface/surfacesFromFlags helpers ensure
both commands construct surfaces identically. surface add POSTs each
surface separately so --before/--after positioning applies per surface.

Closes #151
@benvinegar benvinegar merged commit 132699b into main Jun 27, 2026
9 checks passed
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.

CLI: can't publish a post with multiple surfaces of the same kind (or control order)

1 participant