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

cli

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cli provides the command-line interface with injectable io.Writer for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupService

type BackupService interface {
	BackupProject(cfg *config.Config, project string) backup.BackupResult
	RunBackup(cfg *config.Config) ([]backup.BackupResult, error)
}

BackupService provides backup operations for the CLI.

type CLI

type CLI struct {
	Out     io.Writer // Standard output
	Err     io.Writer // Standard error
	Version string    // Application version
	Args    []string  // Command arguments (like os.Args)

	// Exit function for testability (defaults to os.Exit)
	Exit func(code int)

	// Injectable dependencies (nil means use defaults)
	ConfigSvc   ConfigService
	BackupSvc   BackupService
	RecoverySvc RecoveryService
	LaunchdSvc  LaunchdService
	// contains filtered or unexported fields
}

CLI represents the command-line interface with injectable dependencies.

func New

func New(version string) *CLI

New creates a new CLI with default settings.

func NewForTesting

func NewForTesting(out, errOut io.Writer, args []string) *CLI

NewForTesting creates a CLI configured for testing (no colors, captured output).

func (*CLI) InitConfig

func (c *CLI) InitConfig()

InitConfig creates the default config file.

func (*CLI) InstallLaunchd

func (c *CLI) InstallLaunchd()

InstallLaunchd installs the launchd schedule.

func (*CLI) ListBackups

func (c *CLI) ListBackups()

ListBackups lists all backups for a project.

func (*CLI) MoveBackups added in v1.0.0

func (c *CLI) MoveBackups()

MoveBackups moves all backups to a new location and updates the config.

func (*CLI) PrintUsage

func (c *CLI) PrintUsage()

PrintUsage prints the help message.

func (*CLI) Run

func (c *CLI) Run()

Run executes the CLI with the configured arguments.

func (*CLI) RunBackup

func (c *CLI) RunBackup()

RunBackup runs the backup command.

func (*CLI) RunRecover

func (c *CLI) RunRecover()

RunRecover recovers a project from backup.

func (*CLI) RunVerify

func (c *CLI) RunVerify()

RunVerify verifies a backup.

func (*CLI) ShowStatus

func (c *CLI) ShowStatus()

ShowStatus shows the current status.

func (*CLI) UninstallLaunchd

func (c *CLI) UninstallLaunchd()

UninstallLaunchd removes the launchd schedule.

type ConfigService

type ConfigService interface {
	Load() (*config.Config, error)
	Save(cfg *config.Config) error
	ConfigPath() (string, error)
	DefaultConfig() (*config.Config, error)
}

ConfigService provides configuration operations for the CLI.

type LaunchdService

type LaunchdService interface {
	IsInstalled() bool
	Install(hour, minute int) error
	Uninstall() error
	Status() (bool, error)
	PlistPath() string
	LogPath() string
}

LaunchdService provides launchd operations for the CLI.

type RecoveryService

type RecoveryService interface {
	Verify(cfg *config.Config, project, version string) error
	Recover(cfg *config.Config, opts recovery.RecoverOptions) error
	ListVersions(cfg *config.Config, project string) ([]manifest.BackupEntry, error)
}

RecoveryService provides recovery operations for the CLI.

Jump to

Keyboard shortcuts

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