Documentation
¶
Overview ¶
Package plugin is the Go SDK for lfed plugins. Serve turns a Cobra root command into a conforming lfed plugin binary.
Index ¶
Constants ¶
const ManifestSchemaVersion = "1"
ManifestSchemaVersion is the schema_version the lfed CLI writes and reads.
Variables ¶
This section is empty.
Functions ¶
func Prepare ¶
Prepare wires root for the plugin contract without executing it. Serve calls it; tests call it directly and then root.Execute.
func Serve ¶
Serve runs root as an lfed plugin and exits the process. It adds the hidden `__metadata` command, a persistent -o/--output flag defaulting to LFED_OUTPUT, and fills the manifest's schema version and command list from the Cobra tree when the caller left Commands nil. Errors print as `lfed-<name>: <err>` and exit 1.
Types ¶
type Command ¶
type Command struct {
// Path is the command words below the plugin name, e.g. ["targets","list"].
Path []string `json:"path"`
Summary string `json:"summary"`
}
Command is one leaf command of a plugin, for help output only.
type Manifest ¶
type Manifest struct {
SchemaVersion string `json:"schema_version"`
// Name matches the binary suffix: lfed-<name>.
Name string `json:"name"`
Version string `json:"version"`
// Summary is one line shown by `lfed help` and `lfed plugin list`.
Summary string `json:"summary"`
// RequiresLfed is a semver range such as ">=0.1.0 <1".
RequiresLfed string `json:"requires_lfed"`
// Commands lists leaf commands for help output.
Commands []Command `json:"commands"`
Hidden bool `json:"hidden,omitempty"`
}
Manifest is what `lfed-<name> __metadata` prints and what the lfed CLI stores as lfed-plugin.json in the plugin's install directory.