alias

package
v0.4.33 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 10 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandAlias

type CommandAlias struct {
	Name      string            `yaml:"name"`
	AliasFor  string            `yaml:"aliasFor"`
	Flags     map[string]string `yaml:"flags,omitempty"`
	Arguments []string          `yaml:"arguments,omitempty"`
	Layout    []*layout.Section `yaml:"layout,omitempty"`

	AliasedCommand cmds.Command `yaml:",omitempty"`
	Parents        []string     `yaml:",omitempty"`
	Source         string       `yaml:",omitempty"`
}

CommandAlias defines a struct that should be able to define generic aliases for any kind of command line applications, by providing overrides for certain flags (prepopulating them with certain flags and arguments, basically)

func NewCommandAlias

func NewCommandAlias(options ...Option) *CommandAlias

func NewCommandAliasFromYAML

func NewCommandAliasFromYAML(s io.Reader, options ...Option) (*CommandAlias, error)

func (*CommandAlias) Description

func (a *CommandAlias) Description() *cmds.CommandDescription

Description returns the CommandDescription of an alias. It computes it at runtime by loading the aliased command's Description() and making copies of its flags and arguments. This is necessary because they get mutated at runtime with various defaults, depending on where they come from.

func (*CommandAlias) IsValid

func (a *CommandAlias) IsValid() bool

func (*CommandAlias) Run

func (a *CommandAlias) Run(
	ctx context.Context,
	parsedLayers map[string]*layers.ParsedParameterLayer,
	ps map[string]interface{},
	gp middlewares.Processor,
) error

func (*CommandAlias) String

func (a *CommandAlias) String() string

func (*CommandAlias) ToYAML added in v0.4.0

func (a *CommandAlias) ToYAML(w io.Writer) error

type Option

type Option func(*CommandAlias)

func WithAliasFor

func WithAliasFor(aliasFor string) Option

func WithArguments

func WithArguments(arguments []string) Option

func WithFlags

func WithFlags(flags map[string]string) Option

func WithName

func WithName(name string) Option

func WithParents

func WithParents(parents ...string) Option

func WithPrependSource

func WithPrependSource(source string) Option

func WithSource

func WithSource(source string) Option

func WithStripParentsPrefix

func WithStripParentsPrefix(prefixes []string) Option

Jump to

Keyboard shortcuts

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