Documentation ¶
Index ¶
- func AddCommandsToRootCommand(rootCmd *cobra.Command, commands []cmds.Command, aliases []*cmds.CommandAlias) error
- func AddGlazedProcessorFlagsToCobraCommand(cmd *cobra.Command) error
- func BuildCobraCommand(s cmds.Command) (*cobra.Command, error)
- func BuildCobraCommandAlias(alias *cmds.CommandAlias) (*cobra.Command, error)
- func CreateGlazedProcessorFromCobra(cmd *cobra.Command) (*cmds.GlazeProcessor, formatters.OutputFormatter, error)
- func GatherParametersFromCobraCommand(cmd *cobra.Command, description *cmds.CommandDescription, args []string) (map[string]interface{}, error)
- func SetupProcessor(ps map[string]interface{}) (*cmds.GlazeProcessor, formatters.OutputFormatter, error)
- type FieldsFilterFlagsDefaults
- type FieldsFilterSettings
- type FieldsFiltersParameterLayer
- type GlazeParameterLayerOption
- func WithFieldsFiltersParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
- func WithOutputParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
- func WithRenameParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
- func WithReplaceParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
- func WithSelectParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
- func WithTemplateParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
- type GlazedParameterLayers
- func (g *GlazedParameterLayers) AddFlag(*parameters.ParameterDefinition)
- func (g *GlazedParameterLayers) AddFlagsToCobraCommand(cmd *cobra.Command) error
- func (g *GlazedParameterLayers) GetDescription() string
- func (g *GlazedParameterLayers) GetName() string
- func (g *GlazedParameterLayers) GetParameterDefinitions() map[string]*parameters.ParameterDefinition
- func (g *GlazedParameterLayers) GetPrefix() string
- func (g *GlazedParameterLayers) GetSlug() string
- func (g *GlazedParameterLayers) InitializeParameterDefaultsFromStruct(s interface{}) error
- func (g *GlazedParameterLayers) ParseFlagsFromCobraCommand(cmd *cobra.Command) (map[string]interface{}, error)
- type OutputFlagsDefaults
- type OutputFormatterSettings
- type OutputParameterLayer
- type RenameFlagsDefaults
- type RenameParameterLayer
- type RenameSettings
- type ReplaceFlagsDefaults
- type ReplaceParameterLayer
- type ReplaceSettings
- type SelectFlagsDefaults
- type SelectParameterLayer
- type SelectSettings
- type TemplateFlagsDefaults
- type TemplateFormatterSettings
- type TemplateParameterLayer
- type TemplateSettings
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 BuildCobraCommand ¶ added in v0.2.10
func BuildCobraCommandAlias ¶ added in v0.2.10
func BuildCobraCommandAlias(alias *cmds.CommandAlias) (*cobra.Command, error)
func CreateGlazedProcessorFromCobra ¶ added in v0.2.10
func CreateGlazedProcessorFromCobra(cmd *cobra.Command) ( *cmds.GlazeProcessor, 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.Command` 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 SetupProcessor instead, and create a proper glazed.Command 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 SetupProcessor ¶
func SetupProcessor(ps map[string]interface{}) ( *cmds.GlazeProcessor, formatters.OutputFormatter, error, )
Types ¶
type FieldsFilterSettings ¶
type FieldsFilterSettings struct { Filters []string `glazed.parameter:"filter"` Fields []string `glazed.parameter:"fields"` SortColumns bool `glazed.parameter:"sort-columns"` ReorderColumns []string }
func NewFieldsFilterSettings ¶ added in v0.2.6
func NewFieldsFilterSettings(ps map[string]interface{}) (*FieldsFilterSettings, error)
func (*FieldsFilterSettings) AddMiddlewares ¶
func (ffs *FieldsFilterSettings) AddMiddlewares(of formatters.OutputFormatter)
func (*FieldsFilterSettings) UpdateWithSelectSettings ¶
func (ffs *FieldsFilterSettings) UpdateWithSelectSettings(ss *SelectSettings)
type FieldsFiltersParameterLayer ¶ added in v0.2.10
type FieldsFiltersParameterLayer struct {
*layers.ParameterLayerImpl
}
func NewFieldsFiltersParameterLayer ¶ added in v0.2.10
func NewFieldsFiltersParameterLayer(options ...layers.ParameterLayerOptions) (*FieldsFiltersParameterLayer, error)
func (*FieldsFiltersParameterLayer) AddFlagsToCobraCommand ¶ added in v0.2.10
func (f *FieldsFiltersParameterLayer) AddFlagsToCobraCommand(cmd *cobra.Command) error
func (*FieldsFiltersParameterLayer) ParseFlagsFromCobraCommand ¶ added in v0.2.10
func (f *FieldsFiltersParameterLayer) ParseFlagsFromCobraCommand(cmd *cobra.Command) (map[string]interface{}, error)
type GlazeParameterLayerOption ¶ added in v0.2.19
type GlazeParameterLayerOption func(*GlazedParameterLayers) error
func WithFieldsFiltersParameterLayerOptions ¶ added in v0.2.19
func WithFieldsFiltersParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
func WithOutputParameterLayerOptions ¶ added in v0.2.19
func WithOutputParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
func WithRenameParameterLayerOptions ¶ added in v0.2.19
func WithRenameParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
func WithReplaceParameterLayerOptions ¶ added in v0.2.19
func WithReplaceParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
func WithSelectParameterLayerOptions ¶ added in v0.2.19
func WithSelectParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
func WithTemplateParameterLayerOptions ¶ added in v0.2.19
func WithTemplateParameterLayerOptions(options ...layers.ParameterLayerOptions) GlazeParameterLayerOption
type GlazedParameterLayers ¶ added in v0.2.10
type GlazedParameterLayers struct { FieldsFiltersParameterLayer *FieldsFiltersParameterLayer OutputParameterLayer *OutputParameterLayer RenameParameterLayer *RenameParameterLayer ReplaceParameterLayer *ReplaceParameterLayer SelectParameterLayer *SelectParameterLayer TemplateParameterLayer *TemplateParameterLayer }
func NewGlazedParameterLayers ¶ added in v0.2.10
func NewGlazedParameterLayers(options ...GlazeParameterLayerOption) (*GlazedParameterLayers, error)
func (*GlazedParameterLayers) AddFlag ¶ added in v0.2.10
func (g *GlazedParameterLayers) AddFlag(*parameters.ParameterDefinition)
func (*GlazedParameterLayers) AddFlagsToCobraCommand ¶ added in v0.2.10
func (g *GlazedParameterLayers) AddFlagsToCobraCommand(cmd *cobra.Command) error
func (*GlazedParameterLayers) GetDescription ¶ added in v0.2.13
func (g *GlazedParameterLayers) GetDescription() string
func (*GlazedParameterLayers) GetName ¶ added in v0.2.13
func (g *GlazedParameterLayers) GetName() string
func (*GlazedParameterLayers) GetParameterDefinitions ¶ added in v0.2.10
func (g *GlazedParameterLayers) GetParameterDefinitions() map[string]*parameters.ParameterDefinition
func (*GlazedParameterLayers) GetPrefix ¶ added in v0.2.18
func (g *GlazedParameterLayers) GetPrefix() string
func (*GlazedParameterLayers) GetSlug ¶ added in v0.2.13
func (g *GlazedParameterLayers) GetSlug() string
func (*GlazedParameterLayers) InitializeParameterDefaultsFromStruct ¶ added in v0.2.13
func (g *GlazedParameterLayers) InitializeParameterDefaultsFromStruct(s interface{}) error
func (*GlazedParameterLayers) ParseFlagsFromCobraCommand ¶ added in v0.2.10
func (g *GlazedParameterLayers) ParseFlagsFromCobraCommand(cmd *cobra.Command) (map[string]interface{}, error)
type OutputFlagsDefaults ¶
type OutputFlagsDefaults struct { Output string `glazed.parameter:"output"` OutputFile string `glazed.parameter:"output-file"` TableFormat string `glazed.parameter:"table-format"` WithHeaders bool `glazed.parameter:"with-headers"` CsvSeparator string `glazed.parameter:"csv-separator"` OutputAsObjects bool `glazed.parameter:"output-as-objects"` Flatten bool `glazed.parameter:"flatten"` TemplateFile string `glazed.parameter:"template-file"` }
type OutputFormatterSettings ¶
type OutputFormatterSettings struct { Output string `glazed.parameter:"output"` TableFormat string `glazed.parameter:"table-format"` OutputAsObjects bool `glazed.parameter:"output-as-objects"` FlattenObjects bool `glazed.parameter:"flatten"` WithHeaders bool `glazed.parameter:"with-headers"` CsvSeparator string `glazed.parameter:"csv-separator"` Template string TemplateFormatterSettings *TemplateFormatterSettings }
func NewOutputFormatterSettings ¶ added in v0.2.6
func NewOutputFormatterSettings(ps map[string]interface{}) (*OutputFormatterSettings, error)
func (*OutputFormatterSettings) CreateOutputFormatter ¶
func (ofs *OutputFormatterSettings) CreateOutputFormatter() (formatters.OutputFormatter, error)
func (*OutputFormatterSettings) UpdateWithSelectSettings ¶
func (ofs *OutputFormatterSettings) UpdateWithSelectSettings(ss *SelectSettings)
type OutputParameterLayer ¶ added in v0.2.10
type OutputParameterLayer struct {
*layers.ParameterLayerImpl
}
func NewOutputParameterLayer ¶ added in v0.2.10
func NewOutputParameterLayer(options ...layers.ParameterLayerOptions) (*OutputParameterLayer, error)
type RenameFlagsDefaults ¶
type RenameParameterLayer ¶ added in v0.2.10
type RenameParameterLayer struct {
*layers.ParameterLayerImpl
}
func NewRenameParameterLayer ¶ added in v0.2.10
func NewRenameParameterLayer(options ...layers.ParameterLayerOptions) (*RenameParameterLayer, error)
type RenameSettings ¶
type RenameSettings struct { RenameFields map[types.FieldName]string RenameRegexps middlewares.RegexpReplacements YamlFile string }
func NewRenameSettingsFromParameters ¶ added in v0.2.10
func NewRenameSettingsFromParameters(ps map[string]interface{}) (*RenameSettings, error)
func (*RenameSettings) AddMiddlewares ¶
func (rs *RenameSettings) AddMiddlewares(of formatters.OutputFormatter) error
type ReplaceFlagsDefaults ¶
type ReplaceFlagsDefaults struct { // currently, only support loading replacements from a file ReplaceFile string `glazed.parameter:"replace-file"` }
type ReplaceParameterLayer ¶ added in v0.2.10
type ReplaceParameterLayer struct {
*layers.ParameterLayerImpl
}
func NewReplaceParameterLayer ¶ added in v0.2.10
func NewReplaceParameterLayer(options ...layers.ParameterLayerOptions) (*ReplaceParameterLayer, error)
type ReplaceSettings ¶
type ReplaceSettings struct {
ReplaceFile string `glazed.parameter:"replace-file"`
}
func NewReplaceSettingsFromParameters ¶ added in v0.2.9
func NewReplaceSettingsFromParameters(ps map[string]interface{}) (*ReplaceSettings, error)
func (*ReplaceSettings) AddMiddlewares ¶
func (rs *ReplaceSettings) AddMiddlewares(of formatters.OutputFormatter) error
type SelectFlagsDefaults ¶
type SelectParameterLayer ¶ added in v0.2.10
type SelectParameterLayer struct {
*layers.ParameterLayerImpl
}
func NewSelectParameterLayer ¶ added in v0.2.10
func NewSelectParameterLayer(options ...layers.ParameterLayerOptions) (*SelectParameterLayer, error)
type SelectSettings ¶
type SelectSettings struct { SelectField string `glazed.parameter:"select"` SelectTemplate string `glazed.parameter:"select-template"` }
func NewSelectSettingsFromParameters ¶ added in v0.2.9
func NewSelectSettingsFromParameters(ps map[string]interface{}) (*SelectSettings, error)
type TemplateFlagsDefaults ¶
type TemplateFlagsDefaults struct { Template string `glazed.parameter:"template"` TemplateField map[string]string `glazed.parameter:"template-field"` UseRowTemplates bool `glazed.parameter:"use-row-templates"` }
func NewTemplateFlagsDefaults ¶
func NewTemplateFlagsDefaults() *TemplateFlagsDefaults
type TemplateParameterLayer ¶ added in v0.2.10
type TemplateParameterLayer struct {
*layers.ParameterLayerImpl
}
func NewTemplateParameterLayer ¶ added in v0.2.10
func NewTemplateParameterLayer(options ...layers.ParameterLayerOptions) (*TemplateParameterLayer, error)
type TemplateSettings ¶
type TemplateSettings struct { RenameSeparator string UseRowTemplates bool `glazed.parameter:"use-row-templates"` Templates map[types.FieldName]string }
func NewTemplateSettings ¶ added in v0.2.6
func NewTemplateSettings(parameters map[string]interface{}) (*TemplateSettings, error)
func (*TemplateSettings) AddMiddlewares ¶
func (tf *TemplateSettings) AddMiddlewares(of formatters.OutputFormatter) error
func (*TemplateSettings) UpdateWithSelectSettings ¶
func (tf *TemplateSettings) UpdateWithSelectSettings(ss *SelectSettings)