plugin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const ManifestSchemaVersion = "1"

ManifestSchemaVersion is the schema_version the lfed CLI writes and reads.

Variables

This section is empty.

Functions

func Output

func Output(cmd *cobra.Command) (output.Mode, error)

Output returns the validated -o mode of cmd's tree.

func Prepare

func Prepare(root *cobra.Command, m Manifest)

Prepare wires root for the plugin contract without executing it. Serve calls it; tests call it directly and then root.Execute.

func Serve

func Serve(root *cobra.Command, m Manifest)

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.

Jump to

Keyboard shortcuts

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