Documentation ¶
Index ¶
- type BareCommand
- type Command
- type CommandDescription
- func (cd *CommandDescription) Clone(cloneLayers bool, options ...CommandDescriptionOption) *CommandDescription
- func (cd *CommandDescription) Description() *CommandDescription
- func (cd *CommandDescription) FullPath() string
- func (cd *CommandDescription) GetDefaultArguments() *parameters.ParameterDefinitions
- func (cd *CommandDescription) GetDefaultFlags() *parameters.ParameterDefinitions
- func (cd *CommandDescription) GetDefaultLayer() (layers.ParameterLayer, bool)
- func (cd *CommandDescription) GetLayer(name string) (layers.ParameterLayer, bool)
- func (cd *CommandDescription) ToYAML(w io.Writer) error
- type CommandDescriptionOption
- func WithArguments(arguments ...*parameters.ParameterDefinition) CommandDescriptionOption
- func WithFlags(flags ...*parameters.ParameterDefinition) CommandDescriptionOption
- func WithLayers(ls *layers.ParameterLayers) CommandDescriptionOption
- func WithLayersList(ls ...layers.ParameterLayer) CommandDescriptionOption
- func WithLayout(l *layout.Layout) CommandDescriptionOption
- func WithLong(s string) CommandDescriptionOption
- func WithName(s string) CommandDescriptionOption
- func WithParents(p ...string) CommandDescriptionOption
- func WithPrependSource(s string) CommandDescriptionOption
- func WithReplaceLayers(layers_ ...layers.ParameterLayer) CommandDescriptionOption
- func WithShort(s string) CommandDescriptionOption
- func WithSource(s string) CommandDescriptionOption
- func WithStripParentsPrefix(prefixes []string) CommandDescriptionOption
- type CommandWithMetadata
- type ExitWithoutGlazeError
- type GlazeCommand
- type TemplateCommand
- type TemplateCommandDescription
- type TemplateCommandLoader
- type WriterCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BareCommand ¶ added in v0.2.46
type Command ¶
type Command interface { Description() *CommandDescription ToYAML(w io.Writer) error }
type CommandDescription ¶
type CommandDescription struct { Name string `yaml:"name"` Short string `yaml:"short"` Long string `yaml:"long,omitempty"` // TODO(manuel, 2023-12-21) Does this need to be a list of pointers? Could it just be a list of struct? Layout []*layout.Section `yaml:"layout,omitempty"` Layers *layers.ParameterLayers `yaml:"layers,omitempty"` AdditionalData map[string]interface{} `yaml:"additionalData,omitempty"` Parents []string `yaml:",omitempty"` // Source indicates where the command was loaded from, to make debugging easier. Source string `yaml:",omitempty"` }
CommandDescription contains the necessary information for registering a command with cobra. Because a command gets registered in a verb tree, a full list of Parents all the way to the root needs to be provided.
func NewCommandDescription ¶ added in v0.2.10
func NewCommandDescription(name string, options ...CommandDescriptionOption) *CommandDescription
func (*CommandDescription) Clone ¶ added in v0.2.25
func (cd *CommandDescription) Clone(cloneLayers bool, options ...CommandDescriptionOption) *CommandDescription
func (*CommandDescription) Description ¶ added in v0.4.0
func (cd *CommandDescription) Description() *CommandDescription
func (*CommandDescription) FullPath ¶ added in v0.5.14
func (cd *CommandDescription) FullPath() string
func (*CommandDescription) GetDefaultArguments ¶ added in v0.4.36
func (cd *CommandDescription) GetDefaultArguments() *parameters.ParameterDefinitions
func (*CommandDescription) GetDefaultFlags ¶ added in v0.4.36
func (cd *CommandDescription) GetDefaultFlags() *parameters.ParameterDefinitions
func (*CommandDescription) GetDefaultLayer ¶ added in v0.4.36
func (cd *CommandDescription) GetDefaultLayer() (layers.ParameterLayer, bool)
func (*CommandDescription) GetLayer ¶ added in v0.4.36
func (cd *CommandDescription) GetLayer(name string) (layers.ParameterLayer, bool)
type CommandDescriptionOption ¶ added in v0.2.10
type CommandDescriptionOption func(*CommandDescription)
func WithArguments ¶ added in v0.2.10
func WithArguments( arguments ...*parameters.ParameterDefinition, ) CommandDescriptionOption
WithArguments is a convenience function to add arguments to the default layer, useful to make the transition from explicit flags and arguments to a default layer a bit easier.
func WithFlags ¶ added in v0.2.10
func WithFlags( flags ...*parameters.ParameterDefinition, ) CommandDescriptionOption
WithFlags is a convenience function to add arguments to the default layer, useful to make the transition from explicit flags and arguments to a default layer a bit easier.
func WithLayers ¶ added in v0.2.10
func WithLayers(ls *layers.ParameterLayers) CommandDescriptionOption
func WithLayersList ¶ added in v0.4.36
func WithLayersList(ls ...layers.ParameterLayer) CommandDescriptionOption
func WithLayout ¶ added in v0.2.70
func WithLayout(l *layout.Layout) CommandDescriptionOption
func WithLong ¶ added in v0.2.10
func WithLong(s string) CommandDescriptionOption
func WithName ¶ added in v0.2.25
func WithName(s string) CommandDescriptionOption
func WithParents ¶ added in v0.2.10
func WithParents(p ...string) CommandDescriptionOption
func WithPrependSource ¶ added in v0.2.27
func WithPrependSource(s string) CommandDescriptionOption
func WithReplaceLayers ¶ added in v0.2.25
func WithReplaceLayers(layers_ ...layers.ParameterLayer) CommandDescriptionOption
func WithShort ¶ added in v0.2.10
func WithShort(s string) CommandDescriptionOption
func WithSource ¶ added in v0.2.10
func WithSource(s string) CommandDescriptionOption
func WithStripParentsPrefix ¶ added in v0.2.27
func WithStripParentsPrefix(prefixes []string) CommandDescriptionOption
type CommandWithMetadata ¶ added in v0.4.15
type ExitWithoutGlazeError ¶ added in v0.2.16
type ExitWithoutGlazeError struct{}
func (*ExitWithoutGlazeError) Error ¶ added in v0.2.16
func (e *ExitWithoutGlazeError) Error() string
type GlazeCommand ¶ added in v0.2.45
type GlazeCommand interface { Command // RunIntoGlazeProcessor is called to actually execute the command. // // NOTE(manuel, 2023-02-27) We can probably simplify this to only take parsed layers // // The ps and GlazeProcessor calls could be replaced by a GlazeCommand specific layer, // which would allow the GlazeCommand to parse into a specific struct. The GlazeProcessor // is just something created by the passed in GlazeLayer anyway. // // When we are just left with building a convenience wrapper for Glaze based commands, // instead of forcing it into the upstream interface. // // https://github.com/go-go-golems/glazed/issues/217 // https://github.com/go-go-golems/glazed/issues/216 // See https://github.com/go-go-golems/glazed/issues/173 RunIntoGlazeProcessor(ctx context.Context, parsedLayers *layers.ParsedLayers, gp middlewares.Processor) error }
type TemplateCommand ¶ added in v0.4.12
type TemplateCommand struct { *CommandDescription Template string }
func NewTemplateCommand ¶ added in v0.4.36
func NewTemplateCommand(name string, template string, options ...CommandDescriptionOption) *TemplateCommand
func (*TemplateCommand) IsValid ¶ added in v0.4.12
func (t *TemplateCommand) IsValid() bool
func (*TemplateCommand) RunIntoWriter ¶ added in v0.4.12
func (t *TemplateCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error
type TemplateCommandDescription ¶ added in v0.4.12
type TemplateCommandDescription struct { Name string `yaml:"name"` Short string `yaml:"short"` Long string `yaml:"long,omitempty"` Layout []*layout.Section `yaml:"layout,omitempty"` Flags []*parameters.ParameterDefinition `yaml:"flags,omitempty"` Arguments []*parameters.ParameterDefinition `yaml:"arguments,omitempty"` Layers layers.ParameterLayers `yaml:"layers,omitempty"` Template string `yaml:"template"` }
type TemplateCommandLoader ¶ added in v0.4.12
type TemplateCommandLoader struct{}
func (*TemplateCommandLoader) LoadCommandFromYAML ¶ added in v0.4.12
func (tcl *TemplateCommandLoader) LoadCommandFromYAML( s io.Reader, options ...CommandDescriptionOption, ) ([]Command, error)
type WriterCommand ¶ added in v0.2.46
Click to show internal directories.
Click to hide internal directories.