Problem
Template authors hand-craft install strings like diecut new gh:user/repo/rust-cli for their READMEs. This is error-prone (wrong prefix, wrong subpath, wrong ref, forgetting to update after a repo rename) and discourages pinning to specific versions.
Standing inside a template directory, an author should be able to ask the tool "give me the snippet."
Proposed feature
A new subcommand (working name: diecut share; see open questions) that runs in a template directory and emits the install snippet.
Behavior
- Walk up to git root from cwd
- Read
remote.origin.url (override with --remote <NAME>)
- Parse to
(vendor, owner, repo):
- GitHub / GitLab / Codeberg → emit shortcode form
- Otherwise → emit full URL
- Compute subpath from git root to cwd; append if non-empty
- Default: print
diecut new <snippet> to stdout
--format=markdown → ready-to-paste markdown block
--write <file> → write to file with fence markers (<!-- diecut:install-start --> … <!-- diecut:install-end -->) for idempotent re-runs (updates existing block in place)
--ref <REF> → include --ref <REF> in emitted command for version pinning
- Warn if HEAD isn't pushed to the remote
- Error cleanly when not in a git repo, when no remote configured, or when run outside a template dir (no
diecut.toml under cwd)
Design alternative
Instead of embedding --ref in snippets, we could extend shortcode grammar (gh:owner/repo@ref). Current decision: embed --ref flag — keeps grammar simple, same user outcome. Revisit if needed.
Dependencies
--ref flag comes from the URL-parsing feature (feat: accept full browser URLs). That should land first.
Open questions
- Command name:
share, snippet, info, other?
- Output scope: just the
diecut new line, or include "install diecut first" block? Lean minimal.
Acceptance criteria
Problem
Template authors hand-craft install strings like
diecut new gh:user/repo/rust-clifor their READMEs. This is error-prone (wrong prefix, wrong subpath, wrong ref, forgetting to update after a repo rename) and discourages pinning to specific versions.Standing inside a template directory, an author should be able to ask the tool "give me the snippet."
Proposed feature
A new subcommand (working name:
diecut share; see open questions) that runs in a template directory and emits the install snippet.Behavior
remote.origin.url(override with--remote <NAME>)(vendor, owner, repo):diecut new <snippet>to stdout--format=markdown→ ready-to-paste markdown block--write <file>→ write to file with fence markers (<!-- diecut:install-start -->…<!-- diecut:install-end -->) for idempotent re-runs (updates existing block in place)--ref <REF>→ include--ref <REF>in emitted command for version pinningdiecut.tomlunder cwd)Design alternative
Instead of embedding
--refin snippets, we could extend shortcode grammar (gh:owner/repo@ref). Current decision: embed--refflag — keeps grammar simple, same user outcome. Revisit if needed.Dependencies
--refflag comes from the URL-parsing feature (feat: accept full browser URLs). That should land first.Open questions
share,snippet,info, other?diecut newline, or include "install diecut first" block? Lean minimal.Acceptance criteria
--format=markdown--writewith fence-marker idempotency--refpinning support