utils

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CancelError = errors.New("CancelError")

CancelError signals user-initiated cancellation.

View Source
var ConfigNotFoundError = errors.New("Config file not found")
View Source
var PendingError = errors.New("PendingError")

PendingError signals nothing failed but something is pending.

View Source
var SilentError = errors.New("SilentError")

SilentError is an error that triggers exit code 1 without any error messaging.

Functions

func CompareVersions added in v0.1.0

func CompareVersions(v1, v2 string) int

CompareVersions compares two version strings. It returns:

-1 if v1 < v2
 0 if v1 == v2
 1 if v1 > v2

func ConvertToRawGitHubURL

func ConvertToRawGitHubURL(inputURL string) (string, error)

func FlagErrorWrap

func FlagErrorWrap(err error) error

FlagError returns a new FlagError that wraps the specified error.

func FlagErrorf

func FlagErrorf(format string, args ...interface{}) error

FlagErrorf returns a new FlagError that wraps an error produced by fmt.Errorf(format, args...).

func GetOsInfo

func GetOsInfo() map[string]string

func GetSubcommandNames

func GetSubcommandNames(cmd *cobra.Command) []string

func IsUserCancellation

func IsUserCancellation(err error) bool

func MutuallyExclusive

func MutuallyExclusive(message string, conditions ...bool) error

func PrintCombinedStats added in v0.1.2

func PrintCombinedStats(iostream *iostreams.IOStreams, stats []*Stats)

func PrintWelcomeMessage

func PrintWelcomeMessage(iostream *iostreams.IOStreams, version string)

Types

type ConfigureItem

type ConfigureItem struct {
	Name             string   `yaml:"name"`
	ConfigURL        string   `yaml:"config_url,omitempty"`
	InstallPath      string   `yaml:"install_path"`
	ConfigureCommand []string `yaml:"configure_command,omitempty"`
}

type FlagError

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

A *FlagError indicates an error processing command-line flags or other arguments. Such errors cause the application to display the usage message.

func (*FlagError) Error

func (fe *FlagError) Error() string

func (*FlagError) Unwrap

func (fe *FlagError) Unwrap() error

type NoResultsError

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

func NewNoResultsError

func NewNoResultsError(message string) NoResultsError

func (NoResultsError) Error

func (e NoResultsError) Error() string

type RealUserUtils

type RealUserUtils struct{}

func (RealUserUtils) GetCurrentUser

func (RealUserUtils) GetCurrentUser() (*user.User, error)

func (RealUserUtils) IsAdmin

func (RealUserUtils) IsAdmin(ctx context.Context, u *user.User) bool

type Stats added in v0.1.2

type Stats struct {
	Name      string
	Duration  time.Duration
	Status    string
	Operation string
}

type StatsCollector added in v0.1.2

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

func NewStatsCollector added in v0.1.2

func NewStatsCollector() *StatsCollector

func (*StatsCollector) AddStat added in v0.1.2

func (sc *StatsCollector) AddStat(stat *Stats)

func (*StatsCollector) GetStats added in v0.1.2

func (sc *StatsCollector) GetStats() []*Stats

type Tool

type Tool struct {
	Name           string   `yaml:"name"`
	Method         string   `yaml:"method,omitempty"` // Optional, for specifying 'cask' or other Homebrew methods
	InstallCommand string   `yaml:"install_command,omitempty"`
	PostInstall    []string `yaml:"post_install,omitempty"`
}

type ToolConfig

type ToolConfig struct {
	Tools     []Tool          `yaml:"tools"`
	Configure []ConfigureItem `yaml:"configure"`
}

func LoadToolsConfig

func LoadToolsConfig(filename string) (*ToolConfig, error)

LoadToolsConfig loads tool configuration from a YAML file.

func (*ToolConfig) GetConfigureItem

func (tc *ToolConfig) GetConfigureItem(name string) (*ConfigureItem, error)

GetConfigureItem retrieves a specific configuration item by name.

type UserUtils

type UserUtils interface {
	GetCurrentUser() (*user.User, error)
	IsAdmin(ctx context.Context, u *user.User) bool
}

Jump to

Keyboard shortcuts

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