Help us shape the future of Go! Take the 2026 Go Developer Survey

undo

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package undo provides functionality for undoing stackit operations using snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(ctx *app.Context, opts Options, h Handler) error

Action performs the undo operation

Types

type Handler

type Handler interface {
	// Start is called at the beginning of undo
	Start()

	// OnSnapshotList is called with available snapshots
	OnSnapshotList(snapshots []engine.SnapshotInfo)

	// OnStep is called for each undo step
	OnStep(description string, status handler.StepStatus)

	// Complete is called when undo finishes
	Complete(success bool, message string)

	// Cleanup restores terminal state (may be no-op)
	Cleanup()

	// IsInteractive returns true if the handler supports interactive prompts
	IsInteractive() bool

	// SelectSnapshot prompts user to select a snapshot (interactive only)
	SelectSnapshot(snapshots []engine.SnapshotInfo) (string, error)

	// PromptConfirm prompts user for confirmation (interactive only)
	PromptConfirm(message string, defaultYes bool) (bool, error)
}

Handler receives events from undo action

type NullHandler

type NullHandler struct {
	handler.NullBase
}

NullHandler is a no-op handler for when nil is passed

func (*NullHandler) Complete

func (h *NullHandler) Complete(_ bool, _ string)

Complete implements Handler.

func (*NullHandler) OnSnapshotList

func (h *NullHandler) OnSnapshotList(_ []engine.SnapshotInfo)

OnSnapshotList implements Handler.

func (*NullHandler) OnStep

func (h *NullHandler) OnStep(_ string, _ handler.StepStatus)

OnStep implements Handler.

func (*NullHandler) PromptConfirm

func (h *NullHandler) PromptConfirm(_ string, _ bool) (bool, error)

PromptConfirm implements Handler.

func (*NullHandler) SelectSnapshot

func (h *NullHandler) SelectSnapshot(_ []engine.SnapshotInfo) (string, error)

SelectSnapshot implements Handler.

func (*NullHandler) Start

func (h *NullHandler) Start()

Start implements Handler.

type Options

type Options struct {
	SnapshotID string // Optional: specific snapshot to restore (skips interactive selection)
	Force      bool   // Optional: skip confirmation prompt
}

Options contains options for the undo command

Jump to

Keyboard shortcuts

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