setup

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 12 Imported by: 0

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:

  1. Detect environment (podman + git + GitHub SSH access).
  2. Verify state directories ($XDG_STATE_HOME/a-novel, $XDG_DATA_HOME/a-novel) exist with 0700 perms.
  3. 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.
  4. Shell rc integration: manage a marker-delimited block in the user's shell rc (zshrc / bashrc / fish), with a pre-edit backup.
  5. 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

type Prompter interface {
	YesNo(prompt string) (bool, error)
}

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

func Run(opts Options, w io.Writer, prompter Prompter) (*Result, error)

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

type StdinPrompter struct {
	Out io.Writer
}

StdinPrompter is the canonical implementation backed by os.Stdin.

func (*StdinPrompter) YesNo

func (p *StdinPrompter) YesNo(prompt string) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL