cmdVersion

package module
v0.0.0-...-1b15b8d Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: GPL-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LatestVersion  = "latest"
	LatestSemVer   = "0.0.0"
	CurrentVersion = "current"
	EarliestSemVer = "0.0.1" // Using semver, "0.0.0" is defined as "latest".

	CmdSelfUpdate = "selfupdate"

	CmdVersion       = "version"
	CmdVersionInfo   = "info"
	CmdVersionList   = "list"
	CmdVersionLatest = "latest"
	CmdVersionCheck  = "check"
	CmdVersionUpdate = "update"

	FlagVersion = "version"

	DefaultRepoServer = "github.com"

	BootstrapBinaryName = "bootstrap"
	DefaultVersion      = "0.4.2"
)
View Source
const DefaultVersionTemplate = `
{{with .Name}}{{printf "%s " .}}{{end}} {{printf "version %s" .Version}}
`
View Source
const Group = "Version"

Variables

This section is empty.

Functions

func Close

func Close()

func CompareBinary

func CompareBinary(runtimeBin string, newBin string) error

func CopyFile

func CopyFile(runtimeBin string, targetBin string) error

func Open

func Open(name string, enable bool) (*typeColours, error)

func SprintError

func SprintError(err error) string

func Sprintf

func Sprintf(format string, args ...interface{}) string

func SprintfBlue

func SprintfBlue(format string, args ...interface{}) string

func SprintfCyan

func SprintfCyan(format string, args ...interface{}) string

func SprintfDebug

func SprintfDebug(format string, args ...interface{}) string

func SprintfError

func SprintfError(format string, args ...interface{}) string

func SprintfGreen

func SprintfGreen(format string, args ...interface{}) string

func SprintfInfo

func SprintfInfo(format string, args ...interface{}) string

func SprintfMagenta

func SprintfMagenta(format string, args ...interface{}) string

func SprintfNormal

func SprintfNormal(format string, args ...interface{}) string

func SprintfOk

func SprintfOk(format string, args ...interface{}) string

func SprintfRed

func SprintfRed(format string, args ...interface{}) string

func SprintfWarning

func SprintfWarning(format string, args ...interface{}) string

func SprintfWhite

func SprintfWhite(format string, args ...interface{}) string

func SprintfYellow

func SprintfYellow(format string, args ...interface{}) string

Types

type Environment

type Environment map[string]string

type ExecArgs

type ExecArgs []string

func (*ExecArgs) Add

func (r *ExecArgs) Add(a ...string) *ExecArgs

func (*ExecArgs) Append

func (r *ExecArgs) Append(a ...string) *ExecArgs

func (*ExecArgs) Get

func (r *ExecArgs) Get(index int) string

func (*ExecArgs) GetAll

func (r *ExecArgs) GetAll() []string

func (*ExecArgs) GetFrom

func (r *ExecArgs) GetFrom(lower int) []string

func (*ExecArgs) GetFromSize

func (r *ExecArgs) GetFromSize(begin int, size int) []string

func (*ExecArgs) Range

func (r *ExecArgs) Range(lower int, upper int) []string

func (*ExecArgs) Set

func (r *ExecArgs) Set(a ...string) *ExecArgs

func (*ExecArgs) Sprintf

func (r *ExecArgs) Sprintf() string

func (*ExecArgs) SprintfFrom

func (r *ExecArgs) SprintfFrom(lower int) string

func (*ExecArgs) SprintfFromSize

func (r *ExecArgs) SprintfFromSize(lower int, upper int) string

func (*ExecArgs) SprintfRange

func (r *ExecArgs) SprintfRange(lower int, upper int) string

func (*ExecArgs) String

func (r *ExecArgs) String() string

func (*ExecArgs) ToString

func (r *ExecArgs) ToString() string

type ExecEnv

type ExecEnv []string

type FlagValue

type FlagValue bool

type GoRuntime

type GoRuntime struct {
	Os       string
	Arch     string
	Root     string
	Version  string
	Compiler string
	NumCpus  int
}

type SelfUpdateArgs

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

type State

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

func (*State) GetError

func (s *State) GetError() error

func (*State) GetOk

func (s *State) GetOk() error

func (*State) GetState

func (s *State) GetState() error

func (*State) GetWarning

func (s *State) GetWarning() error

func (*State) IsError

func (s *State) IsError() bool

func (*State) IsNotError

func (s *State) IsNotError() bool

func (*State) IsNotOk

func (s *State) IsNotOk() bool

func (*State) IsOk

func (s *State) IsOk() bool

func (*State) SetError

func (s *State) SetError(format string, args ...interface{})

func (*State) SetOk

func (s *State) SetOk(format string, args ...interface{})

func (*State) SetWarning

func (s *State) SetWarning(format string, args ...interface{})

type StringValue

type StringValue string

func (*StringValue) IsEmpty

func (v *StringValue) IsEmpty() bool

func (*StringValue) IsNil

func (v *StringValue) IsNil() bool

func (*StringValue) IsNotEmpty

func (v *StringValue) IsNotEmpty() bool

func (*StringValue) IsNotNil

func (v *StringValue) IsNotNil() bool

func (*StringValue) IsNotValid

func (v *StringValue) IsNotValid() bool

func (*StringValue) IsValid

func (v *StringValue) IsValid() bool

func (*StringValue) String

func (v *StringValue) String() string

type TargetFile

type TargetFile struct {
	IsMissing       bool
	IsRuntimeBinary bool
	FileMatches     bool
	IsSymlink       bool
	LinkTo          string
	LinkEval        string
	LinkToRuntime   bool
	CopyOfRuntime   bool

	Error error
	Info  os.FileInfo
}

func FileStat

func FileStat(runtimeBinary string, targetBinary string) *TargetFile

type UrlValue

type UrlValue struct {
	*url.URL
	Owner   string
	Name    string
	Version *VersionValue
}

func (*UrlValue) GetShortUrl

func (v *UrlValue) GetShortUrl() string

func (*UrlValue) GetUrl

func (v *UrlValue) GetUrl() string

func (*UrlValue) IsEmpty

func (v *UrlValue) IsEmpty() bool

func (*UrlValue) IsNil

func (v *UrlValue) IsNil() bool

func (*UrlValue) IsNotEmpty

func (v *UrlValue) IsNotEmpty() bool

func (*UrlValue) IsNotNil

func (v *UrlValue) IsNotNil() bool

func (*UrlValue) IsNotValid

func (v *UrlValue) IsNotValid() bool

func (*UrlValue) IsValid

func (v *UrlValue) IsValid() bool

func (*UrlValue) Set

func (v *UrlValue) Set(args ...string) error

func (*UrlValue) String

func (v *UrlValue) String() string

type User

type User struct {
	*user.User
}

type Ux

type Ux struct {
}

func (*Ux) PrintError

func (u *Ux) PrintError(err error)

func (*Ux) Printf

func (u *Ux) Printf(format string, args ...interface{})

func (*Ux) PrintfBlue

func (u *Ux) PrintfBlue(format string, args ...interface{})

func (*Ux) PrintfCyan

func (u *Ux) PrintfCyan(format string, args ...interface{})

func (*Ux) PrintfDebug

func (u *Ux) PrintfDebug(format string, args ...interface{})

func (*Ux) PrintfError

func (u *Ux) PrintfError(format string, args ...interface{})

func (*Ux) PrintfGreen

func (u *Ux) PrintfGreen(format string, args ...interface{})

func (*Ux) PrintfInfo

func (u *Ux) PrintfInfo(format string, args ...interface{})

func (*Ux) PrintfMagenta

func (u *Ux) PrintfMagenta(format string, args ...interface{})

func (*Ux) PrintfNormal

func (u *Ux) PrintfNormal(format string, args ...interface{})

func (*Ux) PrintfOk

func (u *Ux) PrintfOk(format string, args ...interface{})

func (*Ux) PrintfRed

func (u *Ux) PrintfRed(format string, args ...interface{})

func (*Ux) PrintfWarning

func (u *Ux) PrintfWarning(format string, args ...interface{})

func (*Ux) PrintfWhite

func (u *Ux) PrintfWhite(format string, args ...interface{})

func (*Ux) PrintfYellow

func (u *Ux) PrintfYellow(format string, args ...interface{})

func (*Ux) PrintflnBlue

func (u *Ux) PrintflnBlue(format string, args ...interface{})

func (*Ux) PrintflnCyan

func (u *Ux) PrintflnCyan(format string, args ...interface{})

func (*Ux) PrintflnError

func (u *Ux) PrintflnError(format string, args ...interface{})

func (*Ux) PrintflnGreen

func (u *Ux) PrintflnGreen(format string, args ...interface{})

func (*Ux) PrintflnInfo

func (u *Ux) PrintflnInfo(format string, args ...interface{})

func (*Ux) PrintflnMagenta

func (u *Ux) PrintflnMagenta(format string, args ...interface{})

func (*Ux) PrintflnNormal

func (u *Ux) PrintflnNormal(format string, args ...interface{})

func (*Ux) PrintflnOk

func (u *Ux) PrintflnOk(format string, args ...interface{})

func (*Ux) PrintflnRed

func (u *Ux) PrintflnRed(format string, args ...interface{})

func (*Ux) PrintflnWarning

func (u *Ux) PrintflnWarning(format string, args ...interface{})

func (*Ux) PrintflnWhite

func (u *Ux) PrintflnWhite(format string, args ...interface{})

func (*Ux) PrintflnYellow

func (u *Ux) PrintflnYellow(format string, args ...interface{})

type Version

type Version struct {
	ExecName       string   `json:"cmd_name" mapstructure:"cmd_name"`
	ExecVersion    string   `json:"cmd_version" mapstructure:"cmd_version"`
	ExecSourceRepo UrlValue `json:"cmd_source_repo" mapstructure:"cmd_source_repo"`
	ExecBinaryRepo UrlValue `json:"cmd_binary_repo" mapstructure:"cmd_binary_repo"`

	Cmd     string `json:"cmd" mapstructure:"cmd"`
	CmdDir  string `json:"cmd_dir" mapstructure:"cmd_dir"`
	CmdFile string `json:"cmd_file" mapstructure:"cmd_file"`

	WorkingDir *cmdPath.Path `json:"working_dir" mapstructure:"working_dir"`
	BaseDir    *cmdPath.Path `json:"base_dir" mapstructure:"base_dir"`
	BinDir     *cmdPath.Path `json:"bin_dir" mapstructure:"bin_dir"`
	ConfigDir  *cmdPath.Path `json:"config_dir" mapstructure:"config_dir"`
	CacheDir   *cmdPath.Path `json:"cache_dir" mapstructure:"cache_dir"`
	TempDir    *cmdPath.Path `json:"temp_dir" mapstructure:"temp_dir"`

	FullArgs ExecArgs `json:"full_args" mapstructure:"full_args"`
	Args     ExecArgs `json:"args" mapstructure:"args"`
	ArgFiles ExecArgs `json:"arg_files" mapstructure:"arg_files"`

	Env    ExecEnv     `json:"env" mapstructure:"env"`
	EnvMap Environment `json:"env_map" mapstructure:"env_map"`

	TimeStamp time.Time     `json:"timestamp" mapstructure:"timestamp"`
	Timeout   time.Duration `json:"timeout" mapstructure:"timeout"`

	GoRuntime GoRuntime `json:"go_runtime" mapstructure:"go_runtime"`

	User User `json:"user" mapstructure:"user"`

	Debug   bool  `json:"debug" mapstructure:"debug"`
	Verbose bool  `json:"verbose" mapstructure:"verbose"`
	State   State `json:"state" mapstructure:"state"`

	OldVersion    *VersionValue
	TargetBinary  string
	RuntimeBinary string
	AutoExec      bool

	SelfCmd *cobra.Command
	// contains filtered or unexported fields
}

func New

func New(binary string, version string, debugFlag bool) *Version

func (*Version) AddArgs

func (v *Version) AddArgs(a ...string)

func (*Version) AddFullArgs

func (v *Version) AddFullArgs(a ...string)

func (*Version) AttachCommands

func (v *Version) AttachCommands(cmd *cobra.Command, disableVflag bool) State

func (*Version) AutoRun

func (v *Version) AutoRun() State

func (*Version) CmdHelp

func (v *Version) CmdHelp() State

func (*Version) CmdVersion

func (v *Version) CmdVersion(cmd *cobra.Command, args ...string) State

func (*Version) CmdVersionCheck

func (v *Version) CmdVersionCheck() State

func (*Version) CmdVersionInfo

func (v *Version) CmdVersionInfo(args ...string) State

func (*Version) CmdVersionList

func (v *Version) CmdVersionList(args ...string) State

func (*Version) CmdVersionShow

func (v *Version) CmdVersionShow() State

func (*Version) CmdVersionUpdate

func (v *Version) CmdVersionUpdate() State

func (*Version) CreateDummyBinary

func (v *Version) CreateDummyBinary() State

func (*Version) EnsureNotNil

func (v *Version) EnsureNotNil() *Version

func (*Version) FetchVersion

func (v *Version) FetchVersion(version *VersionValue) *selfupdate.Release

func (*Version) FlagCheckVersion

func (v *Version) FlagCheckVersion(cmd *cobra.Command) bool

func (*Version) GetArg

func (v *Version) GetArg(index int) string

func (*Version) GetArgRange

func (v *Version) GetArgRange(lower int, upper int) []string

func (*Version) GetArgs

func (v *Version) GetArgs() []string

func (*Version) GetBinaryRepo

func (v *Version) GetBinaryRepo() string

func (*Version) GetCmd

func (v *Version) GetCmd() *cobra.Command

func (*Version) GetEnvMap

func (v *Version) GetEnvMap() *Environment

func (*Version) GetFullArgs

func (v *Version) GetFullArgs() []string

func (*Version) GetName

func (v *Version) GetName() string

func (*Version) GetNargs

func (v *Version) GetNargs(begin int, size int) []string

func (*Version) GetRepo

func (v *Version) GetRepo() string

func (*Version) GetSemVer

func (v *Version) GetSemVer() *VersionValue

func (*Version) GetSourceRepo

func (v *Version) GetSourceRepo() string

func (*Version) GetTimeout

func (v *Version) GetTimeout() string

func (*Version) GetVersion

func (v *Version) GetVersion() string

func (*Version) GetVersionValue

func (v *Version) GetVersionValue() *VersionValue

func (*Version) IsBootstrapBinary

func (v *Version) IsBootstrapBinary() bool

func (*Version) IsMac

func (v *Version) IsMac() bool

func (*Version) IsNotValid

func (v *Version) IsNotValid() bool

func (*Version) IsOsx

func (v *Version) IsOsx() bool

func (*Version) IsRunningAs

func (v *Version) IsRunningAs(run string) bool

func (*Version) IsRunningAsFile

func (v *Version) IsRunningAsFile() bool
func (v *Version) IsRunningAsLink() bool

func (*Version) IsUpdated

func (v *Version) IsUpdated(print bool) State

func (*Version) IsValid

func (v *Version) IsValid() bool

func (*Version) IsWindows

func (v *Version) IsWindows() bool

func (*Version) PrintNameVersion

func (v *Version) PrintNameVersion()

func (*Version) PrintSummary

func (v *Version) PrintSummary(release *github.RepositoryRelease) State

func (*Version) PrintVersion

func (v *Version) PrintVersion(version *VersionValue) State

func (*Version) PrintVersionSummary

func (v *Version) PrintVersionSummary(version string) State

func (*Version) Set

func (v *Version) Set(s SelfUpdateArgs) State

func (*Version) SetArgs

func (v *Version) SetArgs(a ...string)

func (*Version) SetBinaryRepo

func (v *Version) SetBinaryRepo(value ...string) State

func (*Version) SetCmd

func (v *Version) SetCmd(a ...string) error

func (*Version) SetDebug

func (v *Version) SetDebug(value bool) State

func (*Version) SetFullArgs

func (v *Version) SetFullArgs(a ...string)

func (*Version) SetName

func (v *Version) SetName(value string) State

func (*Version) SetOldVersion

func (v *Version) SetOldVersion(value string) State

func (*Version) SetRepo

func (v *Version) SetRepo(value ...string) State

func (*Version) SetRepos

func (v *Version) SetRepos(source string, binary string) State

func (*Version) SetSourceRepo

func (v *Version) SetSourceRepo(value ...string) State

func (*Version) SetVersion

func (v *Version) SetVersion(value string) State

func (*Version) SprintfArgRange

func (v *Version) SprintfArgRange(lower int, upper int) string

func (*Version) SprintfArgsFrom

func (v *Version) SprintfArgsFrom(lower int) string

func (*Version) SprintfNargs

func (v *Version) SprintfNargs(lower int, upper int) string

func (*Version) TimeStampEpoch

func (v *Version) TimeStampEpoch() int64

func (*Version) TimeStampString

func (v *Version) TimeStampString() string

func (*Version) Update

func (v *Version) Update() State

func (*Version) UpdateTo

func (v *Version) UpdateTo(newVersion *VersionValue) State

type VersionValue

type VersionValue struct {
	semver.Version
	// contains filtered or unexported fields
}
type VersionValue struct {
	semver.Version
	string
}

func GetSemVer

func GetSemVer(v string) *VersionValue

func (*VersionValue) IsLatest

func (v *VersionValue) IsLatest() bool

func (*VersionValue) IsNotValid

func (v *VersionValue) IsNotValid() bool

func (*VersionValue) IsValid

func (v *VersionValue) IsValid() bool

func (*VersionValue) String

func (v *VersionValue) String() string

func (*VersionValue) ToSemVer

func (v *VersionValue) ToSemVer() semver.Version

Jump to

Keyboard shortcuts

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