x

package
v1.4.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 18 Imported by: 0

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.

Functions

func GetPluginDependencies

func GetPluginDependencies() map[string]api.Dependency

GetPluginDependencies returns exec plugin dependencies.

func RunInstalledCommand

func RunInstalledCommand(ctx context.Context, tmp plugin.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"`
	TmpDir    plugin.TmpDir   `yaml:"tmpDir"`
	Logger    config.Logger
}

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 added in v1.3.0

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