Documentation
¶
Index ¶
- Constants
- Variables
- func FormatModules(versions []ModuleVersion) string
- func GetVersion(showShort, needCommit bool) string
- func IsLess(verLeft, verRight Version) bool
- func IsNumericVersion(requested string) bool
- func IsVersion(version string) bool
- func MatchInstalledVersion(requested string, installed []string) (string, error)
- func MatchVersion(expected string, sortedVersions []Version) (string, error)
- func Stamp() string
- type Flavour
- type Info
- type Module
- type ModuleVersion
- type NotFoundError
- type Release
- type ReleaseType
- type Version
- type VersionSlice
Constants ¶
const ( // CliSeparator is used in commands to specify version. E.g: program=version. CliSeparator = "=" // FsSeparator is used in file names to specify version. E.g: program_version. FsSeparator = "_" )
const (
// DefaultTitle is the name tt presents itself under.
DefaultTitle = "Tarantool CLI"
)
Variables ¶
var ( // ErrNotFound reports that no available version matches the requested version. ErrNotFound = errors.New("version not found") // ErrInstalledVersionNotFound reports a request matching no installed version. ErrInstalledVersionNotFound = errors.New("installed version not found") // ErrAmbiguousInstalledVersion reports a request matching multiple installed versions. ErrAmbiguousInstalledVersion = errors.New("more than one installed version matches") )
Functions ¶
func FormatModules ¶
func FormatModules(versions []ModuleVersion) string
FormatModules renders versions one module per line - its name, its version and its Go module - in aligned columns, each line indented by two spaces and ended with a newline.
func GetVersion ¶
GetVersion returns the version of the tt core, in the forms Flavour.GetVersion describes. It is the version the core is, whichever distribution of tt runs it.
func IsNumericVersion ¶
IsNumericVersion reports whether the request has the form X, X.Y, or X.Y.Z.
func MatchInstalledVersion ¶
MatchInstalledVersion resolves X.Y.Z or an exact installation name. A numeric request must match exactly one build, including prereleases and revisions. Partial numbers are never expanded. Literal names such as commit hashes match exactly.
func MatchVersion ¶
MatchVersion takes as input an ascending sorted list of versions. In which it finds the latest version matching the search mask.
It returns NotFoundError wrapping ErrNotFound when no version matches.
func Stamp ¶
func Stamp() string
Stamp returns the version of the tt core the files tt writes record as their author, as in generated_by = "tt <Stamp>" of a lock: the short version of the core; or, for a build no tag the build knows precedes - a development build from a checkout, say - the exact module version Go recorded, a pseudo-version that names the commit; or the commit alone. It is <unknown> only when the build tells none of them.
Types ¶
type Flavour ¶
type Flavour struct {
// Title is the distribution's name. Empty means DefaultTitle.
Title string
// Version is the distribution's version. Nil means the core's.
Version *Info
// Edition, when set, follows the short version as semver build
// metadata: 2.15.0+ee.
Edition string
}
Flavour is how a distribution of tt presents itself: its name and its version. The zero Flavour is tt's own.
func (Flavour) CoreVersion ¶
CoreVersion returns the line tt version shows under the version of a distribution with a version of its own: the version of the tt core it is built on, with the commit. It reports false for a distribution without a version of its own, tt's among them, whose version is the core's.
func (Flavour) Custom ¶
Custom reports whether the distribution presents itself under a name other than tt's own.
func (Flavour) GetVersion ¶
GetVersion returns the distribution's version: in full with its name, the platform and the commit; short, the version alone; or, with needCommit, the version followed by the commit. The edition follows the version in the short forms.
type Info ¶
type Info struct {
// Tag is the tag the build is at or descends from, as git describe
// prints it: v2.15.0, or v2.15.0-3-gabc1234 for a commit past it. The
// version keeps the tag's pre-release but not the commit count and hash.
// Empty means the version is unknown.
Tag string
// Commit is the abbreviated hash of the commit built.
Commit string
// CommitsSinceTag is the number of commits between Tag and Commit. When
// it is not zero the full version shows Tag as well.
CommitsSinceTag int
// Label, when set, follows the version: 2.15.0/label.
Label string
}
Info describes what a build was made from.
type Module ¶
type Module struct {
// Name is the name the table gives the module.
Name string
// Package is the import path of the package of the module's
// constructor.
Package string
}
Module is a module tt is built from, as the table of the core names it.
type ModuleVersion ¶
type ModuleVersion struct {
// Name is the name the table of the core gives the module.
Name string
// Path is the path of the Go module, empty when the build info does not
// record the module of the constructor.
Path string
// Version is the version of the Go module: its own, or the version of
// its replacement when it is replaced by another module, (devel) when it
// is built from a directory, <unknown> when it is not recorded.
Version string
// Replace is the path of the module that replaces it, when that is
// another module; empty otherwise.
Replace string
}
ModuleVersion is a module with the Go module its constructor comes from, as the build info of the binary records it.
func ModuleVersions ¶
func ModuleVersions(modules []Module) []ModuleVersion
ModuleVersions returns the Go modules the constructors of modules come from, in the order of modules, as the build info of the binary records them.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError reports a version request that could not be matched.
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
Error implements the [error] interface.
func (NotFoundError) Unwrap ¶
func (e NotFoundError) Unwrap() error
Unwrap allows errors.Is to recognize ErrNotFound while retaining the requested version.
type Release ¶
type Release struct {
Type ReleaseType
Num uint64
// contains filtered or unexported fields
}
type ReleaseType ¶
type ReleaseType uint16
const ( TypeNightly ReleaseType = iota TypeAlpha TypeBeta TypeRC TypeRelease )
type Version ¶
type Version struct {
Major uint64 // Major.
Minor uint64 // Minor.
Patch uint64 // Patch.
Additional uint64 // Additional commits.
Revision uint64 // Revision number.
Release Release // Release type.
Hash string // Commit hash.
Str string // String representation.
Tarball string // Tarball name.
BuildName string // Custom build name.
}
type VersionSlice ¶
type VersionSlice []Version
VersionSlice attaches the methods of sort.Interface to []Version, sorting from oldest to newest.
func (VersionSlice) Less ¶
func (v VersionSlice) Less(i, j int) bool
Less implements sort.Interface, sorting from oldest to newest.