command

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package command implements a command runner that executes a series of local commands based on a JSON specification. Commands can interpolate user-provided arguments, remote configuration, or outputs from other commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args map[string]string

Args store command specific arguments to be passed to the hook commands.

func (Args) Merge added in v0.1.0

func (a Args) Merge(overrides map[string]string)

Merge merges the provided overrides into the existing args, mutating the existing args.

type Command

type Command struct {
	ID          string   `json:"id"`
	Command     []string `json:"command"`
	Interactive bool     `json:"interactive"`
	DisplayName string   `json:"name"`
}

Command represents a runnable command.

func (Command) Args added in v0.1.0

func (c Command) Args(data TemplateData, options TemplateOptions) ([]string, error)

Args renders the command arguments using the provided template data and options.

func (Command) Display added in v0.0.4

func (c Command) Display(data TemplateData) (string, error)

Display returns the command as a human readable string.

func (Command) Execute added in v0.1.0

func (c Command) Execute(ctx context.Context, config *Config, args Args, outputs Outputs, streams genericclioptions.IOStreams) ([]byte, error)

Execute runs the command with the given config and outputs.

func (Command) Name added in v0.0.3

func (c Command) Name() string

Name returns the name of the program.

func (Command) ToCmd added in v0.1.0

func (c Command) ToCmd(ctx context.Context, data TemplateData) (*exec.Cmd, error)

ToCmd returns a Cmd object that can be used with the exec package.

type Commands

type Commands []*Command

Commands stores a slice of commands and provides some helper execution methods.

func (Commands) Execute added in v0.1.0

func (c Commands) Execute(ctx context.Context, config *Config, args Args, outputs Outputs, streams genericclioptions.IOStreams) (Outputs, error)

Execute runs each command in the calling slice sequentially using the passed config and the outputs accumulated to that point.

type Config

type Config struct {
	LocalPort int
	Verbose   bool
}

Config stores configuration for executing commands.

type Outputs added in v0.0.5

type Outputs map[string]string

Outputs is a collection of command outputs keyed by ID.

func (Outputs) Append added in v0.1.0

func (o Outputs) Append(id string, output string) Outputs

Append copies the existing output, appending the new output, and returns the new, extended outputs.

type TemplateData added in v0.1.0

type TemplateData struct {
	LocalPort int
	Args      Args
	Outputs   map[string]string
}

TemplateData is the data passed to command templates to render the command arguments.

type TemplateOptions added in v0.1.0

type TemplateOptions struct {
	// ShowSensitive indicates whether sensitive values should be shown. When false, sensitive values are replaced with asterisks.
	ShowSensitive bool
}

TemplateOptions are the configurable options used in different rendering contexts.

Jump to

Keyboard shortcuts

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