core

package
v3.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause Imports: 36 Imported by: 0

Documentation

Overview

Package core builds tt from a table of modules and runs it.

A module is an sdk.Constructor: given the Services the core offers, it returns the commands it contributes and where they go. Main calls every constructor, hangs the commands on tt's root, configures tt, hangs the external modules - the executables TT_CLI_MODULES_PATH lists - and runs the command line. A distribution of tt is a main package that calls Main with its table:

func main() {
	os.Exit(core.Main(core.Modules{"builtin": core.Builtin}))
}

Options give the distribution its own name and version (WithFlavour) and its integrity provider (WithIntegrity).

Nothing under cli/ but tt's main package may import this package: the core is built on top of the commands, never the other way round.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Builtin

func Builtin(sdk.Services) []sdk.Mount

Builtin is the module of tt's own commands: the commands tt had before it was built from modules, each mounted at the root as it is.

func Main

func Main(modules Modules, opts ...Option) (code int)

Main builds tt from modules, runs the command line in os.Args and returns the process exit code, having reported the error tt failed with. It may be called once per process.

It boots tt - the integrity provider, global flags, logging - and calls the constructors in the order of their names, then hangs their commands, configures tt, hangs the external modules and runs the command. An external module named like a top-level command takes its place, whoever built it, unless -I is given. Services other than Log are usable from the moment tt is configured. A constructor that panics, a mount the tree cannot hold, a failure to configure tt are reported and end tt with a failure before any command runs; a panic anywhere is reported as an internal error.

Types

type Flavour

type Flavour struct {
	// Title is the distribution's name: "Tarantool CLI EE". Empty means
	// tt's own, "Tarantool CLI"; any other title heads the root help.
	Title string
	// Version is the distribution's version. A zero Version is an unknown
	// one.
	Version VersionInfo
	// Edition, when set, follows the version tt version --short prints, as
	// semver build metadata: "ee" makes it 2.15.0+ee.
	Edition string
}

Flavour is how a distribution of tt presents itself: its name and its version, in the help, in tt version and in the report of an internal error. The version the distribution's core is - the one [platform].tt constraints are checked against and the one written to the files tt generates - stays the core's.

type Modules

type Modules map[string]sdk.Constructor

Modules are the modules tt is built from, by name. The name is the one errors and logs refer to the module by.

type Option

type Option func(*options)

Option configures Main.

func WithFlavour

func WithFlavour(flavour Flavour) Option

WithFlavour makes tt present itself as the distribution flavour describes. Without it tt presents itself as tt.

func WithIntegrity

func WithIntegrity(provider integrity.Provider) Option

WithIntegrity makes tt check integrity with provider: register the integrity flags it has (--integrity-check, --integrity-check-period, --with-integrity-check), check the files of the project and the binaries it runs, and sign and verify what it publishes to and reads from a configuration storage. Without it tt has the disabled provider of integrity.NewDisabledProvider: no integrity flags, no checks. A nil provider is the disabled one.

The provider is the distribution's choice, made once, before any command is built; a module cannot change it.

func WithoutExternalModules

func WithoutExternalModules() Option

WithoutExternalModules builds tt without external modules: tt does not look for them in TT_CLI_MODULES_PATH, has no tt modules command and lists no external commands in its help.

type VersionInfo

type VersionInfo 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. Only
	// its numeric part makes the version. 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 tt version shows Tag as well.
	CommitsSinceTag int
	// Label, when set, follows the version: 2.15.0/label.
	Label string
}

VersionInfo describes what a build of a distribution was made from.

Directories

Path Synopsis
internal
extmod
Package extmod runs tt's external modules: executables found in the directories TT_CLI_MODULES_PATH lists, each run as a top-level command of tt named after the directory that holds it.
Package extmod runs tt's external modules: executables found in the directories TT_CLI_MODULES_PATH lists, each run as a top-level command of tt named after the directory that holds it.
mount
Package mount hangs the commands modules contribute on tt's root command.
Package mount hangs the commands modules contribute on tt's root command.

Jump to

Keyboard shortcuts

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