Documentation ¶
Index ¶
- func DefaultConfigDir() string
- type GitHubDetector
- func (gh *GitHubDetector) LookForGreaterRelease(in LookForGreaterReleaseInput) (LookForGreaterReleaseOutput, error)
- func (gh *GitHubDetector) LookForLatestRelease(in LookForLatestReleaseInput) (LookForLatestReleaseOutput, error)
- func (gh *GitHubDetector) PrintIfFoundGreater(w io.Writer, currentVersion string) error
- func (gh *GitHubDetector) Render(info *Info, isSmartTerminal bool) (string, error)
- type Info
- type IsVerGreaterFunc
- type LookForGreaterReleaseInput
- type LookForGreaterReleaseOutput
- type LookForLatestReleaseInput
- type LookForLatestReleaseOutput
- type Options
- func WithConfigDir(dir string) Options
- func WithFormatting(formatting *style.Formatting) Options
- func WithIsVersionGreater(comparator IsVerGreaterFunc) Options
- func WithLayout(layout *style.Layout) Options
- func WithMinElapseTimeForRecheck(interval time.Duration) Options
- func WithPostRenderHook(renderer PostRenderFunc) Options
- func WithRenderer(renderer RenderFunc) Options
- func WithStateFileName(fileName string) Options
- func WithStyle(cfg *style.Config) Options
- func WithUpdateCheckTimeout(timeout time.Duration) Options
- type PostRenderFunc
- type RenderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigDir ¶ added in v1.1.0
func DefaultConfigDir() string
DefaultConfigDir returns config directory.
Path precedence: 1. VERSION_CONFIG_DIR, 2. XDG_CONFIG_HOME, 3. HOME.
Types ¶
type GitHubDetector ¶
type GitHubDetector struct {
// contains filtered or unexported fields
}
GitHubDetector provides functionality to check GitHub for project's latest release.
func NewGitHubDetector ¶
func NewGitHubDetector(owner, repo string, opts ...Options) *GitHubDetector
NewGitHubDetector returns GitHubDetector instance.
func (*GitHubDetector) LookForGreaterRelease ¶ added in v1.1.0
func (gh *GitHubDetector) LookForGreaterRelease(in LookForGreaterReleaseInput) (LookForGreaterReleaseOutput, error)
LookForGreaterRelease checks project's latest release. In most cases, PrintIfFoundGreater is better option.
func (*GitHubDetector) LookForLatestRelease ¶
func (gh *GitHubDetector) LookForLatestRelease(in LookForLatestReleaseInput) (LookForLatestReleaseOutput, error)
LookForLatestRelease checks project's latest release. In most cases, PrintIfFoundGreater is better option.
Deprecated and will be removed in 1.4.0 release, use LookForGreaterRelease instead.
Old: LookForLatestRelease(upgrade.LookForLatestReleaseInput{CurrentVersion: currentVersion}) New: LookForGreaterRelease(upgrade.LookForGreaterReleaseInput{CurrentVersion: currentVersion})
func (*GitHubDetector) PrintIfFoundGreater ¶
func (gh *GitHubDetector) PrintIfFoundGreater(w io.Writer, currentVersion string) error
PrintIfFoundGreater prints an upgrade notice if a newer version is available. It's a syntax sugar for using the LookForGreaterRelease and Render functions.
type Info ¶
type Info struct { // Version represents a current CLI version. Version string // NewVersion represents the newest CLI version. NewVersion string // ReleaseURL represents the GitHub release URL. ReleaseURL string // IsFromCache if true, the external call was not executed and version was taken from state file. IsFromCache bool }
Info contains upgrade related information.
type IsVerGreaterFunc ¶
IsVerGreaterFunc represents version check function signature.
type LookForGreaterReleaseInput ¶ added in v1.1.0
type LookForGreaterReleaseInput struct {
CurrentVersion string
}
LookForGreaterReleaseInput holds input data for LookForGreaterRelease function.
type LookForGreaterReleaseOutput ¶ added in v1.1.0
LookForGreaterReleaseOutput holds output data for LookForGreaterRelease function.
type LookForLatestReleaseInput ¶
type LookForLatestReleaseInput struct {
CurrentVersion string
}
LookForLatestReleaseInput holds input data for LookForLatestRelease function.
type LookForLatestReleaseOutput ¶
LookForLatestReleaseOutput holds output data for LookForLatestRelease function.
type Options ¶
type Options func(options *GitHubDetector)
Options represents function mutating default options.
func WithConfigDir ¶ added in v1.1.0
WithConfigDir sets the config dir path where cache is stored (state file). If not set, directory is selected in such order:
- VERSION_CONFIG_DIR environment variable
- XDG_CONFIG_HOME environment variable
- os.UserHomeDir()
func WithFormatting ¶
func WithFormatting(formatting *style.Formatting) Options
WithFormatting sets a custom pretty formatting.
func WithIsVersionGreater ¶
func WithIsVersionGreater(comparator IsVerGreaterFunc) Options
WithIsVersionGreater sets a custom function to compare release versions. Defaults to a SemVer check.
func WithLayout ¶
WithLayout sets a custom pretty layout.
func WithMinElapseTimeForRecheck ¶
WithMinElapseTimeForRecheck sets the minimum time that must elapse before checking for a new release. When interval > 0, a state file is created. If interval = 0, state file is not created and each time external call is executed. Defaults to 0.
func WithPostRenderHook ¶
func WithPostRenderHook(renderer PostRenderFunc) Options
WithPostRenderHook sets a custom post render function.
func WithRenderer ¶
func WithRenderer(renderer RenderFunc) Options
WithRenderer sets a custom renderer function.
func WithStateFileName ¶ added in v1.1.0
WithStateFileName sets the state file name. Defaults to {repo_owner}/{repo_name}
func WithUpdateCheckTimeout ¶
WithUpdateCheckTimeout sets max duration time for update check operation. Defaults to 10s.
type PostRenderFunc ¶
PostRenderFunc represents post render function signature.