stew

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatchAndExit

func CatchAndExit(err error)

CatchAndExit will catch errors and immediately exit

func Contains

func Contains(slice []string, target string) (int, bool)

Contains checks if a string slice contains a given target

func DeleteAssetAndBinary

func DeleteAssetAndBinary(stewPkgPath, stewBinPath, asset, binary string) error

DeleteAssetAndBinary will delete the asset from the ~/.stew/pkg path and delete the binary from the ~/.stew/bin path

func DetectAsset

func DetectAsset(userOS string, userArch string, releaseAssets []string) (string, error)

DetectAsset will automatically detect a release asset matching your systems OS/arch or prompt you to manually select an asset

func DownloadFile

func DownloadFile(downloadPath string, url string) error

DownloadFile will download a file from url to a given path

func FormatSearchResults added in v0.2.0

func FormatSearchResults(ghSearch GithubSearch) []string

FormatSearchResults formats the GitHub search results for the terminal UI

func GetGithubReleasesAssets

func GetGithubReleasesAssets(ghProject GithubProject, tag string) ([]string, error)

GetGithubReleasesAssets gets a string slice of the assets for a GithubRelease

func GetGithubReleasesTags

func GetGithubReleasesTags(ghProject GithubProject) ([]string, error)

GetGithubReleasesTags gets a string slice of the releases for a GithubProject

func InstallBinary

func InstallBinary(downloadedFilePath string, repo string, systemInfo SystemInfo, lockFile *LockFile, overwriteFromUpgrade bool) (string, error)

InstallBinary will extract the binary and copy it to the ~/.stew/bin path

func PathExists

func PathExists(path string) (bool, error)

PathExists checks if a given path exists

func PromptSelect

func PromptSelect(message string, options []string) (string, error)

PromptSelect launches the selection UI

func ReadStewfileContents

func ReadStewfileContents(stewfilePath string) ([]string, error)

ReadStewfileContents will read the contents of the Stewfile

func ValidateCLIInput

func ValidateCLIInput(cliInput string) error

ValidateCLIInput makes sure the CLI input isn't empty

func ValidateGithubSearchQuery added in v0.2.0

func ValidateGithubSearchQuery(searchQuery string) error

ValidateGithubSearchQuery makes sure the GitHub search query is valid

func WarningPromptConfirm

func WarningPromptConfirm(message string) (bool, error)

WarningPromptConfirm launches the confirm UI with a warning styling

func WarningPromptSelect

func WarningPromptSelect(message string, options []string) (string, error)

WarningPromptSelect launches the selection UI with a warning styling

func WriteLockFileJSON

func WriteLockFileJSON(lockFileJSON LockFile, outputPath string) error

WriteLockFileJSON will write the lockfile JSON file

Types

type AbortBinaryOverwriteError

type AbortBinaryOverwriteError struct {
	Binary string
}

AbortBinaryOverwriteError occurs if the overwrite of a binary is aborted

func (AbortBinaryOverwriteError) Error

type AlreadyInstalledLatestTagError

type AlreadyInstalledLatestTagError struct {
	Tag string
}

AlreadyInstalledLatestTagError occurs if you try to upgrade a binary but the latest version is already installed

func (AlreadyInstalledLatestTagError) Error

type AssetAlreadyDownloadedError

type AssetAlreadyDownloadedError struct {
	Asset string
}

AssetAlreadyDownloadedError occurs if the requested asset has already been downloaded

func (AssetAlreadyDownloadedError) Error

type AssetsNotFoundError

type AssetsNotFoundError struct {
	Tag string
}

AssetsNotFoundError occurs if no assets are found for a GitHub release

func (AssetsNotFoundError) Error

func (e AssetsNotFoundError) Error() string

type BinaryNotInstalledError

type BinaryNotInstalledError struct {
	Binary string
}

BinaryNotInstalledError occurs if you try to operate on a binary that is not installed

func (BinaryNotInstalledError) Error

func (e BinaryNotInstalledError) Error() string

type CLIFlagAndInputError added in v0.2.0

type CLIFlagAndInputError struct {
}

CLIFlagAndInputError occurs if you try to use a CLI flag with a CLI input at the same time

func (CLIFlagAndInputError) Error added in v0.2.0

func (e CLIFlagAndInputError) Error() string

type CLIInput

type CLIInput struct {
	IsGithubInput bool
	Owner         string
	Repo          string
	Tag           string
	Asset         string
	DownloadURL   string
}

CLIInput contains information about the parsed CLI input

func ParseCLIInput

func ParseCLIInput(cliInput string) (CLIInput, error)

ParseCLIInput creates a new instance of the CLIInput struct

type EmptyCLIInputError

type EmptyCLIInputError struct {
}

EmptyCLIInputError occurs if the CLI input is empty

func (EmptyCLIInputError) Error

func (e EmptyCLIInputError) Error() string

type ExitUserSelectionError

type ExitUserSelectionError struct {
	Err error
}

ExitUserSelectionError occurs when exiting from the terminal UI

func (ExitUserSelectionError) Error

func (e ExitUserSelectionError) Error() string

type GithubAPIResponse

type GithubAPIResponse []GithubRelease

GithubAPIResponse is the response from the GitHub releases API

type GithubAsset

type GithubAsset struct {
	Name        string `json:"name"`
	DownloadURL string `json:"browser_download_url"`
	Size        int    `json:"size"`
	ContentType string `json:"content_type"`
}

GithubAsset contains information about a specific GitHub asset

type GithubProject

type GithubProject struct {
	Owner    string
	Repo     string
	Releases GithubAPIResponse
}

GithubProject contains information about the GitHub project including GitHub releases

func NewGithubProject

func NewGithubProject(owner, repo string) (GithubProject, error)

NewGithubProject creates a new instance of the GithubProject struct

type GithubRelease

type GithubRelease struct {
	TagName string        `json:"tag_name"`
	Assets  []GithubAsset `json:"assets"`
}

GithubRelease contains information about a GitHub release, including the associated assets

type GithubSearch added in v0.2.0

type GithubSearch struct {
	SearchQuery string
	Count       int                  `json:"total_count"`
	Items       []GithubSearchResult `json:"items"`
}

GithubSearch contains information about the GitHub search including the GitHub search results

func NewGithubSearch added in v0.2.0

func NewGithubSearch(searchQuery string) (GithubSearch, error)

NewGithubSearch creates a new instance of the GithubSearch struct

type GithubSearchResult added in v0.2.0

type GithubSearchResult struct {
	FullName    string `json:"full_name"`
	Stars       int    `json:"stargazers_count"`
	Language    string `json:"language"`
	Description string `json:"description"`
}

GithubSearchResult contains information about the GitHub search result

type IndexOutOfBoundsInLockfileError

type IndexOutOfBoundsInLockfileError struct {
}

IndexOutOfBoundsInLockfileError occurs if you try to access an out-of-bounds index in the lockfile packages

func (IndexOutOfBoundsInLockfileError) Error

type InstalledFromURLError

type InstalledFromURLError struct {
	Binary string
}

InstalledFromURLError occurs if you try to perform GitHub specific actions on a binary installed directly from a URL

func (InstalledFromURLError) Error

func (e InstalledFromURLError) Error() string

type InvalidGithubSearchQueryError added in v0.2.0

type InvalidGithubSearchQueryError struct {
	SearchQuery string
}

InvalidGithubSearchQueryError occurs if the GitHub search query contains invalid characters

func (InvalidGithubSearchQueryError) Error added in v0.2.0

type LockFile

type LockFile struct {
	Os       string        `json:"os"`
	Arch     string        `json:"arch"`
	Packages []PackageData `json:"packages"`
}

LockFile contains all the data for the lockfile

func NewLockFile

func NewLockFile(stewLockFilePath, userOS, userArch string) (LockFile, error)

NewLockFile creates a new instance of the LockFile struct

type NoBinariesInstalledError

type NoBinariesInstalledError struct {
}

NoBinariesInstalledError occurs if you try to operate on a binary but no binaries are installed

func (NoBinariesInstalledError) Error

func (e NoBinariesInstalledError) Error() string

type NoGithubSearchResultsError added in v0.2.0

type NoGithubSearchResultsError struct {
	SearchQuery string
}

NoGithubSearchResultsError occurs if the GitHub search API returns no items

func (NoGithubSearchResultsError) Error added in v0.2.0

type NoPackagesInLockfileError

type NoPackagesInLockfileError struct {
}

NoPackagesInLockfileError occurs if you try to remove packages from a lockfile without any packages

func (NoPackagesInLockfileError) Error

type NonZeroStatusCodeDownloadError

type NonZeroStatusCodeDownloadError struct {
	StatusCode int
}

NonZeroStatusCodeDownloadError occurs if a non-zero status code is received when trying to download a file

func (NonZeroStatusCodeDownloadError) Error

type NonZeroStatusCodeError

type NonZeroStatusCodeError struct {
	StatusCode int
}

NonZeroStatusCodeError occurs if a non-zero status code is received from an HTTP request

func (NonZeroStatusCodeError) Error

func (e NonZeroStatusCodeError) Error() string

type PackageData

type PackageData struct {
	Source string `json:"source"`
	Owner  string `json:"owner"`
	Repo   string `json:"repo"`
	Tag    string `json:"tag"`
	Asset  string `json:"asset"`
	Binary string `json:"binary"`
	URL    string `json:"url"`
}

PackageData contains the information for an installed binary

func RemovePackage

func RemovePackage(pkgs []PackageData, index int) ([]PackageData, error)

RemovePackage will remove a package from a LockFile.Packages slice

type ReleasesNotFoundError

type ReleasesNotFoundError struct {
	Owner string
	Repo  string
}

ReleasesNotFoundError occurs if no releases are found for a GitHub repo

func (ReleasesNotFoundError) Error

func (e ReleasesNotFoundError) Error() string

type StewpathNotFoundError added in v0.2.0

type StewpathNotFoundError struct {
	StewPath string
}

StewpathNotFoundError occurs if the ~/.stew path is not found

func (StewpathNotFoundError) Error added in v0.2.0

func (e StewpathNotFoundError) Error() string

type SystemInfo

type SystemInfo struct {
	Os               string
	Arch             string
	StewPath         string
	StewBinPath      string
	StewPkgPath      string
	StewLockFilePath string
	StewTmpPath      string
}

SystemInfo contains system specific info like OS, arch, and ~/.stew paths

func NewSystemInfo

func NewSystemInfo() (SystemInfo, error)

NewSystemInfo creates a new instance of the SystemInfo struct

type UnrecognizedInputError

type UnrecognizedInputError struct {
}

UnrecognizedInputError occurs if the input is not recognized as a URL or GitHub repo

func (UnrecognizedInputError) Error

func (e UnrecognizedInputError) Error() string

Jump to

Keyboard shortcuts

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