x

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 18 Imported by: 0 modules, 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

Index

Constants

View Source
const (
	RawOutputIndicator   = "@raw"
	SelectIndexIndicator = "@idx:"
	PageIndexIndicator   = "@page:"
)

Variables

View Source
var BuiltinCmdPrefix = "exec run"

BuiltinCmdPrefix defines a plugin prefix. It's useful to change it if x lib is used as SDK in different executor plugins.

View Source
var (
	//go:embed config_schema_fmt.json
	ConfigJSONSchemaFmt string
)

Functions

func GetPluginDependencies

func GetPluginDependencies() map[string]api.Dependency

GetPluginDependencies returns exec plugin dependencies.

func RunInstalledCommand

func RunInstalledCommand(ctx context.Context, tmp pluginx.TmpDir, in string, envs map[string]string) (string, error)

RunInstalledCommand runs a given user command for already installed CLIs.

Types

type Command

type Command struct {
	ToExecute     string
	IsRawRequired bool
	PageIndex     int
}

Command holds command details.

func Parse

func Parse(cmd string) Command

Parse returns parsed command string.

type Config

type Config struct {
	Templates []getter.Source `yaml:"templates"`
	Logger    config.Logger

	// Fields not exposed to the user in the JSON schema
	TmpDir pluginx.TmpDir `yaml:"tmpDir"`
}

Config holds exec plugin configuration.

type Render

type Render interface {
	// RenderMessage receives command output and a template and produce a final message.
	RenderMessage(cmd, output string, state *state.Container, msgCtx *template.Template) (api.Message, error)
}

Render is an interface that knows how to render a given command output.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer provides functionality to render command output in requested format.

func NewRenderer

func NewRenderer() *Renderer

NewRenderer returns a new Renderer instance.

func (*Renderer) Get

func (r *Renderer) Get(output string) (Render, error)

Get return renderer for a given output

func (*Renderer) Register

func (r *Renderer) Register(name string, render Render) error

func (*Renderer) RegisterAll

func (r *Renderer) RegisterAll(in map[string]Render) error

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner runs command and parse its output if needed.

func NewRunner

func NewRunner(log logrus.FieldLogger, renderer *Renderer) *Runner

NewRunner returns a new Runner instance.

func (*Runner) Run

func (i *Runner) Run(ctx context.Context, cfg Config, state *state.Container, cmd Command, runFn func() (string, error)) (executor.ExecuteOutput, error)

Run runs a given command and parse its output if needed.

func (*Runner) RunWithTemplates

func (i *Runner) RunWithTemplates(templates []template.Template, state *state.Container, cmd Command, runFn func() (string, error)) (executor.ExecuteOutput, error)

RunWithTemplates runs a given command and parse its output if needed. It uses specified templates instead of downloading them.

Directories

Path Synopsis
Package getter.
Package getter.

Jump to

Keyboard shortcuts

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