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
- Variables
- func FormatBool(b bool) string
- func FormatInt(i, defaultVal int) string
- func ParseParallel(v string, defaultVal int) int
- func ParsePort(v string) int
- func SanitizeTokenForDisplay(token string) string
- func ValidateCloneProto(v string) error
- func ValidateNotEmpty(v string) error
- func ValidateOrganization(v string) error
- func ValidateParallel(v string) error
- func ValidatePath(v string) error
- func ValidatePathRequired(v string) error
- func ValidatePort(v string) error
- func ValidateProfileName(v string) error
- func ValidateProvider(v string) error
- func ValidateProviderRequired(v string) error
- func ValidateSubgroupMode(v string) error
- func ValidateToken(v string) error
- func ValidateURL(v string) error
- func ValidateURLRequired(v string) error
- type BranchCleanupOptions
- type BranchCleanupResult
- type BranchCleanupWizard
- type Printer
- func (p *Printer) PrintDivider()
- func (p *Printer) PrintError(msg string)
- func (p *Printer) PrintHeader(icon, title string)
- func (p *Printer) PrintInfo(msg string)
- func (p *Printer) PrintKeyValue(key, value string)
- func (p *Printer) PrintNextSteps(steps []string)
- func (p *Printer) PrintOrderedSummary(title string, keys []string, items map[string]string)
- func (p *Printer) PrintSubtitle(title string)
- func (p *Printer) PrintSuccess(msg string)
- func (p *Printer) PrintSummary(title string, items map[string]string)
- func (p *Printer) PrintWarning(msg string)
- type ProfileCreateWizard
- type SyncSetupOptions
- type SyncSetupWizard
Constants ¶
const ( IconSuccess = "✓" IconError = "✗" IconWarning = "⚠" IconRocket = "🚀" IconBroom = "🧹" IconGear = "⚙" IconInfo = "ℹ" IconArrow = "→" )
Icons for wizard output.
Variables ¶
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 ParseParallel ¶
ParseParallel parses a parallel count string to int, returning default for empty/invalid.
func SanitizeTokenForDisplay ¶
SanitizeTokenForDisplay masks a token for display.
func ValidateCloneProto ¶
ValidateCloneProto validates the clone protocol.
func ValidateNotEmpty ¶
ValidateNotEmpty validates that a string is not empty.
func ValidateOrganization ¶
ValidateOrganization validates an organization/group name.
func ValidateParallel ¶
ValidateParallel validates a parallel count string.
func ValidatePath ¶
ValidatePath validates a directory path. Returns nil for empty values (optional field).
func ValidatePathRequired ¶
ValidatePathRequired validates a non-empty path.
func ValidateProfileName ¶
ValidateProfileName validates a profile name.
func ValidateProvider ¶
ValidateProvider validates that the value is a valid provider name. Returns nil for empty values (optional field).
func ValidateProviderRequired ¶
ValidateProviderRequired validates that the value is a valid, non-empty provider.
func ValidateSubgroupMode ¶
ValidateSubgroupMode validates the subgroup mode.
func ValidateToken ¶
ValidateToken validates a token (can be actual token or env var reference).
func ValidateURL ¶
ValidateURL validates a URL string. Returns nil for empty values (optional field).
func ValidateURLRequired ¶
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 ¶
func (w *BranchCleanupWizard) Run(ctx context.Context) (*BranchCleanupResult, error)
Run executes the branch cleanup wizard.
type Printer ¶
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 ¶
PrintError prints an error message.
func (*Printer) PrintHeader ¶
PrintHeader prints a wizard header with icon.
func (*Printer) PrintKeyValue ¶
PrintKeyValue prints a key-value pair.
func (*Printer) PrintNextSteps ¶
PrintNextSteps prints next steps.
func (*Printer) PrintOrderedSummary ¶
PrintOrderedSummary prints a configuration summary in order.
func (*Printer) PrintSubtitle ¶
PrintSubtitle prints a section subtitle.
func (*Printer) PrintSuccess ¶
PrintSuccess prints a success message.
func (*Printer) PrintSummary ¶
PrintSummary prints a configuration summary.
func (*Printer) PrintWarning ¶
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.
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 ¶
func (w *SyncSetupWizard) Run(_ context.Context) (*SyncSetupOptions, error)
Run executes the sync setup wizard.