Skip to content

feat: diecut share — generate install snippets from a template directory #134

Description

@raiderrobert

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

  • Subcommand wired up
  • Remote detection + shortcode derivation for big-three vendors
  • Subpath detection for multi-template repos
  • Stdout default + --format=markdown
  • --write with fence-marker idempotency
  • --ref pinning support
  • Unpushed-HEAD warning
  • Error paths (no git repo, no remote, unknown vendor fallback)
  • Tests
  • Docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions