Documentation
¶
Overview ¶
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.
A module's directory holds a manifest (manifest.yaml) naming the module's executable, its version and its one-line help, or an executable named main that prints the version and the help when called with --description --version. The manifest is read, and the executable is read before each call, through tt's integrity checks: a module whose files they refuse is not run.
Mount hangs a proxy command for every module at tt's root. The proxy takes its arguments as they are, flags included, runs the module with them on tt's standard streams and ends tt with the module's exit code. A module named like a command at the root takes the command's place, subcommands and all, unless -I keeps tt's own; only the debug log says that it does. A module with no command of its name is added. Mount also adds tt modules, which lists the modules.
Index ¶
Constants ¶
const PathEnv = "TT_CLI_MODULES_PATH"
PathEnv is the environment variable that lists the directories external modules are found in, separated by colons.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manifest ¶
type Manifest struct {
// Name of module.
Name string `yaml:"-"`
// Version of module.
Version string `yaml:"version"`
// Main is name of executable file.
Main string `yaml:"main"`
// Help is the module's one-line description, which tt lists the module
// with: the first line of the help its manifest, or its reply to
// --description, gives.
Help string `yaml:"help"`
// TtVersion is required a version of TT CLI (optional).
TtVersion string `yaml:"tt-version"`
// Description is a full description of the module (optional).
// It can be used in the future for the help command.
Description string `yaml:"description"`
// Homepage is a link to the module homepage (optional).
Homepage string `yaml:"homepage_url"`
}
Manifest stores information about Tarantool CLI module.
func Mount ¶
Mount finds the external modules opts.Path lists and hangs a proxy for each at root, then adds tt modules. It returns the modules tt runs or would run without -I, sorted by name: the ones tt modules lists and the root help shows under EXTERNAL COMMANDS.
A module is skipped, with a warning, when it cannot be described - no manifest and no answer to --description --version, a manifest the integrity checks refuse or, for a module with no manifest, an executable they refuse, a manifest that does not parse -, when it is named like one of the protected commands, and when the tree cannot hold its command, such as when the name is another command's alias. A module with a manifest whose executable the checks refuse is kept: its runs and its help fail. Mount fails when a directory opts.Path lists is not one or cannot be read, and when tt modules cannot be added.
type Opener ¶
type Opener func(path string) (io.ReadCloser, error)
Opener opens a file for reading through tt's integrity checks: a file they refuse is not opened, or fails while it is read.
type Options ¶
type Options struct {
// Path lists the directories to find modules in, separated by colons:
// the value of PathEnv.
Path string
// Open reads the files of the modules through tt's integrity checks.
Open Opener
// ForceInternal keeps every command of tt in its place: -I.
ForceInternal bool
// Registry records which module each command of the tree comes from.
Registry *mount.Registry
// Reserved is what no module may take.
Reserved mount.Reserved
// Log receives the warnings about the modules and, at the debug level,
// the commands they replace.
Log *slog.Logger
// Streams are the streams a module runs attached to and tt modules
// lists the modules on.
Streams output.Streams
}
Options are what Mount needs from tt.