Documentation
¶
Index ¶
- Constants
- Variables
- func AssetName(version string) string
- func BoolToInt(b bool) int
- func ChecksumVerifiedReader(r io.Reader, expected string) (io.Reader, error)
- func CommandExists(command string) bool
- func ConfirmOrAbort(message, errormsg string) error
- func CreateFile(path string, content any, fileType string, perm os.FileMode) error
- func CreateStatusTable(title string, packages []PackageStatus)
- func DefaultLookForFileInPath(file string) (string, error)
- func DefaultUpdateState() map[string]interface{}
- func DeferRestore(key, val string)
- func EnsureUpdateStateFileExists() (string, error)
- func FileExists(path string) (bool, error)
- func FileReader(path string, fileType string, out interface{}) error
- func Filter[T any](in []T, keep func(T) bool) []T
- func Flat[T any](slices [][]T) []T
- func GenerateRandomString(length int) string
- func GetHomeDir() string
- func GetMaxWidth(lines []string) int
- func GzipBytes(src []byte) ([]byte, error)
- func HumanSize(bytes int64) string
- func Includes[T comparable](in []T, target T) bool
- func InstalledSet(r runner.CommandRunner) (map[string]bool, error)
- func IsHomebrewInstalled() bool
- func IsNewerVersion(remote, local string) (bool, error)
- func IsSemver(v string) bool
- func Keys[K comparable, V any](m map[K]V) []K
- func LessByTypeThenKey(typeA, typeB, keyA, keyB string) bool
- func ListInstalled(r runner.CommandRunner) ([]string, error)
- func MakeFilePath(dir string, filename string) string
- func Map[T any, R any](in []T, f func(T) R) []R
- func MaybeGunzip(src io.ReadCloser) (io.ReadCloser, error)
- func MustSet(key, val string) (old string)
- func NewBytesReadSeekCloser(b []byte) io.ReadSeekCloser
- func NewUpdateState(base config.UpdateState, isNewer bool, version string) config.UpdateState
- func PackageManager() (pmCmd, error)
- func ParseChecksumsForBinary(body, tag string) (string, error)
- func ParseSecureURL(raw string) (*url.URL, error)
- func RunBrewCommand(r runner.CommandRunner, action, pkg string, ignoreWarnings []string) error
- func SetHomebrewPath() error
- func Some[T any](in []T, pred func(T) bool) bool
- func SortByTypeAndKey[T any](xs []T, typeOf func(T) string, keyOf func(T) string)
- func StripANSI(input string) string
- func TransformToMap[T any](lines []string, transform func(string) (string, T)) map[string]T
- func TypeRank(t string) int
- func ValidateBinaryArgs(args []string, binary string) error
- func ValidateSHA256Checksum(filePath, expectedChecksum string) (err error)
- func ValidateVersion(info *VersionInfo) error
- func WarnBrewInstallation(path string)
- func WriteFileAtomic(tmpPath, finalPath string, r io.Reader) error
- func WriteJSONAtomic(path string, v any) error
- type PackageStatus
- type VersionInfo
Constants ¶
const ( FileTypeJSON = "json" FileTypeYAML = "yaml" FileTypeBinary = "binary" )
const ( CacheDir = ".local/state/keg" OutdatedFile = "keg_brew_update.json" CacheExpiry = 24 * time.Hour )
Variables ¶
var LookForFileInPath = DefaultLookForFileInPath
Functions ¶
func ChecksumVerifiedReader ¶
ChecksumVerifiedReader returns a new reader if SHA256 checksum matches.
func CommandExists ¶
commandExists Verify if a command exists in the system
func ConfirmOrAbort ¶
func CreateFile ¶
func CreateStatusTable ¶
func CreateStatusTable(title string, packages []PackageStatus)
func DefaultLookForFileInPath ¶ added in v0.2.0
func DefaultUpdateState ¶
func DefaultUpdateState() map[string]interface{}
func DeferRestore ¶
func DeferRestore(key, val string)
func FileExists ¶
func FileReader ¶
func GenerateRandomString ¶
func GetHomeDir ¶
func GetHomeDir() string
func GetMaxWidth ¶
func Includes ¶
func Includes[T comparable](in []T, target T) bool
func InstalledSet ¶ added in v0.2.1
func InstalledSet(r runner.CommandRunner) (map[string]bool, error)
InstalledSet returns a fast membership map of installed brew formulae. Key: package name, Value: true if installed.
func IsHomebrewInstalled ¶
func IsHomebrewInstalled() bool
IsHomebrewInstalled Verify if Homebrew is already installed
func IsNewerVersion ¶
IsNewerVersion compares two semantic versions and returns true if remote > local.
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
func LessByTypeThenKey ¶ added in v0.1.6
LessByTypeThenKey applies (type rank) then (alpha by key, case-insensitive).
func ListInstalled ¶ added in v0.2.1
func ListInstalled(r runner.CommandRunner) ([]string, error)
ListInstalled returns the installed brew formulae as a slice (if you ever need it).
func MakeFilePath ¶
func MaybeGunzip ¶ added in v0.2.0
func MaybeGunzip(src io.ReadCloser) (io.ReadCloser, error)
maybeGunzip returns a reader that yields the decompressed stream if 'src' is gzip, else returns src as-is. It preserves the ability to Close().
func NewBytesReadSeekCloser ¶ added in v0.2.0
func NewBytesReadSeekCloser(b []byte) io.ReadSeekCloser
func NewUpdateState ¶
func NewUpdateState(base config.UpdateState, isNewer bool, version string) config.UpdateState
func PackageManager ¶ added in v0.1.3
func PackageManager() (pmCmd, error)
func ParseChecksumsForBinary ¶
func RunBrewCommand ¶
func RunBrewCommand(r runner.CommandRunner, action, pkg string, ignoreWarnings []string) error
RunBrewCommand executes a brew command and handles warnings
func SetHomebrewPath ¶
func SetHomebrewPath() error
func SortByTypeAndKey ¶ added in v0.1.6
SortByTypeAndKey sorts any slice using extractor funcs.
func TransformToMap ¶
func ValidateBinaryArgs ¶
func ValidateSHA256Checksum ¶
ValidateSHA256Checksum verifies if the SHA256 hash of the file matches the expected checksum.
func ValidateVersion ¶
func ValidateVersion(info *VersionInfo) error
func WarnBrewInstallation ¶
func WarnBrewInstallation(path string)