Documentation ¶
Index ¶
- func AddCommandsToRootCommand(rootCmd *cobra.Command, commands []cmds.Command, aliases []*alias.CommandAlias) error
- func AddGlazedProcessorFlagsToCobraCommand(cmd *cobra.Command, options ...settings.GlazeParameterLayerOption) error
- func BuildCobraCommandAlias(alias *alias.CommandAlias) (*cobra.Command, error)
- func BuildCobraCommandFromBareCommand(c cmds.BareCommand) (*cobra.Command, error)
- func BuildCobraCommandFromCommand(command cmds.Command) (*cobra.Command, error)
- func BuildCobraCommandFromCommandAndFunc(s cmds.Command, run CobraRunFunc) (*cobra.Command, error)
- func BuildCobraCommandFromGlazeCommand(cmd_ cmds.GlazeCommand) (*cobra.Command, error)
- func BuildCobraCommandFromWriterCommand(s cmds.WriterCommand) (*cobra.Command, error)
- func CreateGlazedProcessorFromCobra(cmd *cobra.Command) (*middlewares.TableProcessor, formatters.OutputFormatter, error)
- func GatherParametersFromCobraCommand(cmd *cobra.Command, description *cmds.CommandDescription, args []string) (map[string]interface{}, error)
- func GetVerbsFromCobraCommand(cmd *cobra.Command) []string
- type CobraParameterLayer
- type CobraParser
- type CobraRunFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCommandsToRootCommand ¶ added in v0.2.10
func AddGlazedProcessorFlagsToCobraCommand ¶ added in v0.2.10
func AddGlazedProcessorFlagsToCobraCommand(cmd *cobra.Command, options ...settings.GlazeParameterLayerOption) error
AddGlazedProcessorFlagsToCobraCommand is a helper for cobra centric apps that quickly want to add the glazed processing layer.
func BuildCobraCommandAlias ¶ added in v0.2.10
func BuildCobraCommandAlias(alias *alias.CommandAlias) (*cobra.Command, error)
func BuildCobraCommandFromBareCommand ¶ added in v0.2.69
func BuildCobraCommandFromBareCommand(c cmds.BareCommand) (*cobra.Command, error)
func BuildCobraCommandFromCommand ¶ added in v0.2.47
func BuildCobraCommandFromCommandAndFunc ¶ added in v0.4.3
func BuildCobraCommandFromGlazeCommand ¶ added in v0.2.46
func BuildCobraCommandFromGlazeCommand(cmd_ cmds.GlazeCommand) (*cobra.Command, error)
func BuildCobraCommandFromWriterCommand ¶ added in v0.2.47
func BuildCobraCommandFromWriterCommand(s cmds.WriterCommand) (*cobra.Command, error)
func CreateGlazedProcessorFromCobra ¶ added in v0.2.10
func CreateGlazedProcessorFromCobra(cmd *cobra.Command) (*middlewares.TableProcessor, formatters.OutputFormatter, error)
CreateGlazedProcessorFromCobra is a helper for cobra centric apps that quickly want to add the glazed processing layer.
If you are more serious about using glazed, consider using the `cmds.GlazeCommand` and `parameters.ParameterDefinition` abstraction to define your CLI applications, which allows you to use layers and other nice features of the glazed ecosystem.
If so, use SetupTableProcessor instead, and create a proper glazed.GlazeCommand for your command.
func GatherParametersFromCobraCommand ¶ added in v0.2.10
func GatherParametersFromCobraCommand( cmd *cobra.Command, description *cmds.CommandDescription, args []string, ) (map[string]interface{}, error)
GatherParametersFromCobraCommand takes a cobra command, an argument list as well as a description of the command, and returns a list of parsed parameters as a hashmap. It does so by parsing both the flags and the positional arguments.
TODO(manuel, 2021-02-04) This function should return how a parameter was set This would match warg's behaviour. It would also make it possible for us to record if it was set from ENV, from the query, from default, frmo which config file, etc...
func GetVerbsFromCobraCommand ¶ added in v0.2.55
Types ¶
type CobraParameterLayer ¶ added in v0.2.46
type CobraParameterLayer interface { // AddFlagsToCobraCommand adds all the flags defined in this layer to the given cobra command. // // NOTE(manuel, 2023-02-27) This can be moved to use that ParameterLayerParser API // As I'm working out what it means to parse layers and use it to fill structs, // and how defaults should be registered, it makes sense to move this out. // Further more, defaults should probably be managed in the layer entirely, and // thus not be shown in the interface here. // // Do we want to keep the parsers in the layer itself, so that when a command is registered, // it gets registered here? Or should the parsers and registerers be outside, // and generic enough to be able to process all the layers of a command without // the command framework knowing about it. This seems to make more sense. AddFlagsToCobraCommand(cmd *cobra.Command) error ParseFlagsFromCobraCommand(cmd *cobra.Command) (map[string]interface{}, error) }
type CobraParser ¶ added in v0.2.46
CobraParser takes a CommandDescription, and hooks it up to a cobra command. It can then be used to parse the cobra flags and arguments back into a set of ParsedParameterLayer and a map[string]interface{} for the lose stuff.
That command however doesn't have a Run method, which is left to the caller to implement.
This returns a CobraParser that can be used to parse the registered layers from the description.
func NewCobraParserFromCommandDescription ¶ added in v0.2.46
func NewCobraParserFromCommandDescription(description *cmds.CommandDescription) (*CobraParser, error)
func (*CobraParser) Parse ¶ added in v0.2.46
func (c *CobraParser) Parse(args []string) (map[string]*layers.ParsedParameterLayer, map[string]interface{}, error)