Documentation
¶
Overview ¶
Package setup implements `a-novel core setup` — the interactive first-time bootstrap. Idempotent: re-running on an already-set-up system performs zero filesystem writes and exits 0.
Sequence:
- Detect environment (podman + git + GitHub SSH access).
- Verify state directories ($XDG_STATE_HOME/a-novel, $XDG_DATA_HOME/a-novel) exist with 0700 perms.
- Per-stack bootstrap: for every entry in $A_NOVEL_STACKS, run the three-way check (exists+valid / exists+invalid / missing). Default stack prompts on missing; non-default clones unconditionally.
- Shell rc integration: manage a marker-delimited block in the user's shell rc (zshrc / bashrc / fish), with a pre-edit backup.
- Print a summary with the "next step" hint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
RCPath string // explicit shell rc path; empty = autodetect
NoShellRC bool // skip the shell rc step entirely
NoStartDaemon bool // skip the auto-start-daemon step at the end
NonInteractive bool // disables prompts (for CI / tests)
// StartDaemon, if non-nil, is invoked as the final step of Run after
// rc edits succeed. It should start the daemon (idempotent: a no-op
// when one is already running). Wiring it from the cli package
// (which already has `startDetached`) keeps setup free of an import
// cycle with internal/cli.
StartDaemon func() error
}
Options carries CLI-supplied overrides for the setup run.
type Prompter ¶
Prompter is the interactive prompt interface used for default-stack clone confirmation. Implementations should write the prompt + read one line; return ("y" | "yes") for yes, anything else for no.
type Result ¶
type Result struct {
PodmanOK bool
GitOK bool
GitHubSSHOK bool
StateDir string
DataDir string
Stacks []StackResult
RCEdited bool
RCPath string
BackupPath string // path of the pre-edit backup, if we wrote one
DaemonStarted bool // true if Run successfully launched the daemon
DaemonNote string // failure reason when DaemonStarted is false
Notes []string // free-form messages (e.g., "stack X already cloned")
}
Result reports what setup did, for the summary at the end.
func Run ¶
Run executes the full bootstrap sequence with the given Options. The `prompter` reads user input when interactive prompts are needed (default-stack clone confirmation). Pass nil for non-interactive modes — missing default stack then becomes a "refused" outcome.
Writes step-by-step progress to `w` so the user can follow along.
type StackResult ¶
type StackResult struct {
Name string
Path string
Status string // "valid" | "cloned" | "skipped" | "refused"
Detail string
}
StackResult is the per-stack bootstrap outcome.
type StdinPrompter ¶
StdinPrompter is the canonical implementation backed by os.Stdin.