app

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Self = "self"

	CommandUpdate    = "update"
	CommandUninstall = "uninstall"
	CommandVersion   = "version"
	CommandHelp      = "help"
)

Variables

View Source
var ErrNotSelfCommand = errors.New("not a self command")

ErrNotSelfCommand is returned when the command is not a self command.

Functions

func HandleAppVersion added in v0.2.0

func HandleAppVersion(ldFlagVersion, versionSource string) (string, string)

HandleAppVersion handles the app binary version.

func HandleError added in v0.2.0

func HandleError(appName string, err error)

HandleError prints error messages and exits with status code 1.

Types

type App

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

App represents the main app.

func NewAppGitBack added in v0.2.0

func NewAppGitBack(version, versionSource string) *App

NewAppGitBack creates a new App instance for git-back.

func NewAppGitUndo added in v0.2.0

func NewAppGitUndo(version string, versionSource string) *App

NewAppGitUndo creates a new App instance.

func (*App) HandleVersion added in v0.2.0

func (a *App) HandleVersion(verbose bool) error

HandleVersion handles the --version flag by delegating to SelfController.

func (*App) Run

func (a *App) Run(ctx context.Context, opts RunOptions) error

Run executes the app with parsed options.

type GitHelper

type GitHelper interface {
	GetCurrentGitRef() (string, error)
	GetRepoGitDir() (string, error)

	GitRun(subCmd string, args ...string) error
	GitOutput(subCmd string, args ...string) (string, error)
}

GitHelper provides methods for reading git references.

type RunOptions added in v0.2.0

type RunOptions struct {
	Verbose     bool
	DryRun      bool
	HookCommand string
	ShowLog     bool
	Args        []string
}

RunOptions contains parsed CLI options.

type SelfController added in v0.1.1

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

SelfController handles self-management commands that don't require a git repository.

func NewSelfController added in v0.1.1

func NewSelfController(version, versionSource string, verbose bool, appName string) *SelfController

NewSelfController creates a new SelfController instance.

func (*SelfController) AddScript added in v0.1.1

func (sc *SelfController) AddScript(cmdName, script string) *SelfController

func (*SelfController) ExtractSelfCommand added in v0.1.1

func (sc *SelfController) ExtractSelfCommand(args []string) string

ExtractSelfCommand checks if the given arguments represent a self-management command.

func (*SelfController) HandleSelfCommand added in v0.1.1

func (sc *SelfController) HandleSelfCommand(args []string) error

HandleSelfCommand processes self-management commands and returns true if handled. Returns (handled, error) where handled indicates if the command was a self command.

Jump to

Keyboard shortcuts

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