alias

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 9 Imported by: 14

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"`
	Short     string            `yaml:"short,omitempty"`
	Long      string            `yaml:"long,omitempty"`
	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) RunIntoGlazeProcessor added in v0.4.36

func (a *CommandAlias) RunIntoGlazeProcessor(ctx context.Context, parsedLayers *layers.ParsedLayers, gp middlewares.Processor) error

func (*CommandAlias) RunIntoWriter added in v0.4.36

func (a *CommandAlias) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) 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