wizard

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package wizard provides interactive setup wizards for gz-git commands.

The wizard package uses charmbracelet/huh for form-based interactive input, guiding users through complex configuration tasks step by step.

Available Wizards:

  • SyncSetup: Configure repository synchronization from Git forges
  • BranchCleanup: Interactive branch cleanup across repositories
  • ProfileCreate: Create configuration profiles

Example usage:

wizard := wizard.NewSyncSetupWizard()
opts, err := wizard.Run(ctx)
if err != nil {
    return err
}
// Use opts to run sync

Index

Constants

View Source
const (
	IconSuccess = "✓"
	IconError   = "✗"
	IconWarning = "⚠"
	IconRocket  = "🚀"
	IconBroom   = "🧹"
	IconGear    = "⚙"
	IconInfo    = "ℹ"
	IconArrow   = "→"
)

Icons for wizard output.

Variables

View Source
var (
	// TitleStyle is used for wizard titles.
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("62")).
				MarginBottom(1)

	// SubtitleStyle is used for section headers.
	SubtitleStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color("245"))

	// SuccessStyle is used for success messages.
	SuccessStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("42"))

	// ErrorStyle is used for error messages.
	ErrorStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("9"))

	// WarningStyle is used for warning messages.
	WarningStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("11"))

	// DimStyle is used for less important text.
	DimStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("240"))

	// KeyStyle is used for config keys.
	KeyStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("45"))

	// ValueStyle is used for config values.
	ValueStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("252"))
)

Styles for wizard output.

Functions

func FormatBool

func FormatBool(b bool) string

FormatBool formats a boolean for display.

func FormatInt

func FormatInt(i, defaultVal int) string

FormatInt formats an integer for display, returning "(default)" for zero values.

func ParseParallel

func ParseParallel(v string, defaultVal int) int

ParseParallel parses a parallel count string to int, returning default for empty/invalid.

func ParsePort

func ParsePort(v string) int

ParsePort parses a port string to int, returning 0 for empty/invalid.

func SanitizeTokenForDisplay

func SanitizeTokenForDisplay(token string) string

SanitizeTokenForDisplay masks a token for display.

func ValidateCloneProto

func ValidateCloneProto(v string) error

ValidateCloneProto validates the clone protocol.

func ValidateNotEmpty

func ValidateNotEmpty(v string) error

ValidateNotEmpty validates that a string is not empty.

func ValidateOrganization

func ValidateOrganization(v string) error

ValidateOrganization validates an organization/group name.

func ValidateParallel

func ValidateParallel(v string) error

ValidateParallel validates a parallel count string.

func ValidatePath

func ValidatePath(v string) error

ValidatePath validates a directory path. Returns nil for empty values (optional field).

func ValidatePathRequired

func ValidatePathRequired(v string) error

ValidatePathRequired validates a non-empty path.

func ValidatePort

func ValidatePort(v string) error

ValidatePort validates a port number string.

func ValidateProfileName

func ValidateProfileName(v string) error

ValidateProfileName validates a profile name.

func ValidateProvider

func ValidateProvider(v string) error

ValidateProvider validates that the value is a valid provider name. Returns nil for empty values (optional field).

func ValidateProviderRequired

func ValidateProviderRequired(v string) error

ValidateProviderRequired validates that the value is a valid, non-empty provider.

func ValidateSubgroupMode

func ValidateSubgroupMode(v string) error

ValidateSubgroupMode validates the subgroup mode.

func ValidateToken

func ValidateToken(v string) error

ValidateToken validates a token (can be actual token or env var reference).

func ValidateURL

func ValidateURL(v string) error

ValidateURL validates a URL string. Returns nil for empty values (optional field).

func ValidateURLRequired

func ValidateURLRequired(v string) error

ValidateURLRequired validates a non-empty URL.

Types

type BranchCleanupOptions

type BranchCleanupOptions struct {
	Directory      string
	IncludeMerged  bool
	IncludeStale   bool
	IncludeGone    bool
	StaleThreshold time.Duration
	Force          bool
	IncludeRemote  bool
}

BranchCleanupOptions holds the results of the branch cleanup wizard.

type BranchCleanupResult

type BranchCleanupResult struct {
	ReposProcessed  int
	BranchesDeleted int
	BranchesSkipped int
	Errors          []string
}

BranchCleanupResult holds the results of cleanup execution.

type BranchCleanupWizard

type BranchCleanupWizard struct {
	// contains filtered or unexported fields
}

BranchCleanupWizard guides users through branch cleanup.

func NewBranchCleanupWizard

func NewBranchCleanupWizard(directory string) *BranchCleanupWizard

NewBranchCleanupWizard creates a new branch cleanup wizard.

func (*BranchCleanupWizard) Run

Run executes the branch cleanup wizard.

type Printer

type Printer struct {
	Out io.Writer
}

Printer handles wizard output.

func NewPrinter

func NewPrinter() *Printer

NewPrinter creates a new Printer with stdout as default.

func (*Printer) PrintDivider

func (p *Printer) PrintDivider()

PrintDivider prints a horizontal divider.

func (*Printer) PrintError

func (p *Printer) PrintError(msg string)

PrintError prints an error message.

func (*Printer) PrintHeader

func (p *Printer) PrintHeader(icon, title string)

PrintHeader prints a wizard header with icon.

func (*Printer) PrintInfo

func (p *Printer) PrintInfo(msg string)

PrintInfo prints an info message.

func (*Printer) PrintKeyValue

func (p *Printer) PrintKeyValue(key, value string)

PrintKeyValue prints a key-value pair.

func (*Printer) PrintNextSteps

func (p *Printer) PrintNextSteps(steps []string)

PrintNextSteps prints next steps.

func (*Printer) PrintOrderedSummary

func (p *Printer) PrintOrderedSummary(title string, keys []string, items map[string]string)

PrintOrderedSummary prints a configuration summary in order.

func (*Printer) PrintSubtitle

func (p *Printer) PrintSubtitle(title string)

PrintSubtitle prints a section subtitle.

func (*Printer) PrintSuccess

func (p *Printer) PrintSuccess(msg string)

PrintSuccess prints a success message.

func (*Printer) PrintSummary

func (p *Printer) PrintSummary(title string, items map[string]string)

PrintSummary prints a configuration summary.

func (*Printer) PrintWarning

func (p *Printer) PrintWarning(msg string)

PrintWarning prints a warning message.

type ProfileCreateWizard

type ProfileCreateWizard struct {
	// contains filtered or unexported fields
}

ProfileCreateWizard guides users through profile creation.

func NewProfileCreateWizard

func NewProfileCreateWizard(name string) *ProfileCreateWizard

NewProfileCreateWizard creates a new profile creation wizard.

func (*ProfileCreateWizard) Run

Run executes the profile creation wizard.

type SyncSetupOptions

type SyncSetupOptions struct {
	Provider         string
	Organization     string
	BaseURL          string
	Token            string
	CloneProto       string
	SSHPort          int
	IncludeSubgroups bool
	SubgroupMode     string
	TargetPath       string
	IncludeArchived  bool
	IncludePrivate   bool
	IncludeForks     bool
	SaveConfig       bool
	ConfigPath       string
	ExecuteNow       bool
	Parallel         int
}

SyncSetupOptions holds the results of the sync setup wizard.

type SyncSetupWizard

type SyncSetupWizard struct {
	// contains filtered or unexported fields
}

SyncSetupWizard guides users through sync setup.

func NewSyncSetupWizard

func NewSyncSetupWizard() *SyncSetupWizard

NewSyncSetupWizard creates a new sync setup wizard.

func (*SyncSetupWizard) BuildCommand

func (w *SyncSetupWizard) BuildCommand() string

BuildCommand returns the equivalent CLI command for the options.

func (*SyncSetupWizard) Run

Run executes the sync setup wizard.

Jump to

Keyboard shortcuts

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