feat(cli): repeatable surface flags + id-leading-separator fix#169
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two changes, one PR:
1. Repeatable surface flags (closes #151)
sideshow publishandsideshow surface addnow 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
parseArgssilently kept only the last value of a repeated non-multipleflag. All seven surface flags (--md,--mermaid,--diff,--terminal,--json,--code,--image) are nowmultiple: truein both commands. SharedbuildSurface/surfacesFromFlagshelpers ensure both commands construct surfaces identically.surface addPOSTs each surface separately so--before/--afterpositioning applies per surface.2. Fix: ids starting with
-or_no longer break CLInewIdemits base64url ids where+→-and/→_, so ~1/64 of ids started with a separator.parseArgsstrict 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:
newIdswaps a leading separator for an alphanumeric — new ids are always CLI-safe.Parser fix:
parse()swaps id-shaped-/_-prefixed tokens for a sentinel beforeparseArgssees 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— cleannpm run lint— cleannpm run format:check— cleanpublish repeats a surface flag to add several of the same kind, in orderandsurface add repeats a flag to append several of the same kind, in order-ids under concurrent test load) is gone