Skip to content

sp new --stdin: headless scratch capture from a pipe (#27) - #29

Merged
rwrife merged 1 commit into
mainfrom
issue-27-stdin-capture
Jul 11, 2026
Merged

sp new --stdin: headless scratch capture from a pipe (#27)#29
rwrife merged 1 commit into
mainfrom
issue-27-stdin-capture

Conversation

@rwrife

@rwrife rwrife commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Closes #27

What changed

Adds a headless capture path to sp new so scratchpatch can ingest content programmatically instead of always shelling out to $EDITOR:

  • --stdin — read content from standard input (pipes, heredocs)
  • --content "<text>" — one-liner content
  • --from-file <path> — seed from an existing file

Any of these suppresses $EDITOR. Exactly one source per invocation (conflicts error out). Interactive sp new is unchanged when none are set.

Implementation

  • New store.WriteContent seeds a scratch's content file and refreshes recorded size (reuses the existing create/index/live-path machinery).
  • captureContent helper gathers + validates the source; TTY-with-no-pipe on --stdin refuses rather than hanging; --content "" is a deliberate empty scratch.
  • Because content lands on disk, sp ls's live secret scan flags piped-in credentials with 🔑 and sp promote guards them — same as editor scratches. No metadata/source-of-truth changes.

Acceptance criteria

  • --stdin reads stdin, no $EDITOR
  • Honors --ttl/--ext/--tag
  • --content and --from-file companions
  • Empty stdin/--content handled deliberately (empty scratch)
  • Stable created scratch <id> anchor preserved
  • Secret scanner runs on captured content (🔑 in sp ls)
  • --stdin on a bare TTY doesn't hang (refuses)
  • Tests: stdin capture, flag combos, secret detection, editor-not-invoked, conflicting sources
  • README documents the pipe workflow
  • go build/go vet/go test ./.../gofmt clean

Testing

go build ./..., go vet ./..., gofmt -l (clean), go test ./... all green; manual smoke test of pipe capture, --content, and the 🔑 marker on a piped secret.

@rwrife
rwrife merged commit 861b9d3 into main Jul 11, 2026
1 check passed
@rwrife
rwrife deleted the issue-27-stdin-capture branch July 11, 2026 09:01
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.

[feature] sp new --stdin / quick-capture from a pipe (headless scratch creation)

1 participant