command

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandHandler

type CommandHandler struct {
	DevMode bool

	// TemplateName is the name of the template that is lookup up through the given TemplateLookup
	// used to render the glazed command.
	TemplateName string
	// TemplateLookup is used to look up both TemplateName and IndexTemplateName
	TemplateLookup render.TemplateLookup

	// can be any of BareCommand, WriterCommand or GlazeCommand
	Command cmds.GlazeCommand

	// AdditionalData is passed to the template being rendered.
	AdditionalData map[string]interface{}

	OverridesAndDefaults *config.OverridesAndDefaults

	// If true, all glazed outputs will try to use a row output if possible.
	// This means that "ragged" objects (where columns might not all be present)
	// will have missing columns, only the fields of the first object will be used
	// as rows.
	//
	// This is true per default, and needs to be explicitly set to false to use
	// a normal TableMiddleware oriented output.
	Stream bool
}

func NewCommandHandler

func NewCommandHandler(
	command cmds.GlazeCommand,
	options ...CommandHandlerOption,
) *CommandHandler

func NewCommandHandlerFromConfig

func NewCommandHandlerFromConfig(
	config_ *config.Command,
	loader loaders.FSCommandLoader,
	options ...CommandHandlerOption,
) (*CommandHandler, error)

func (*CommandHandler) Serve

func (ch *CommandHandler) Serve(server *parka.Server, path string) error

type CommandHandlerOption

type CommandHandlerOption func(*CommandHandler)

func WithDefaultTemplateName

func WithDefaultTemplateName(defaultTemplateName string) CommandHandlerOption

func WithDevMode

func WithDevMode(devMode bool) CommandHandlerOption

func WithMergeAdditionalData

func WithMergeAdditionalData(data map[string]interface{}, override bool) CommandHandlerOption

WithMergeAdditionalData merges the passed in map with the handler's AdditionalData map. If a value is already set in the AdditionalData map and override is true, it will get overwritten.

func WithOverridesAndDefaults

func WithOverridesAndDefaults(overridesAndDefaults *config.OverridesAndDefaults) CommandHandlerOption

func WithOverridesAndDefaultsOptions

func WithOverridesAndDefaultsOptions(opts ...config.OverridesAndDefaultsOption) CommandHandlerOption

func WithTemplateLookup

func WithTemplateLookup(templateLookup render.TemplateLookup) CommandHandlerOption

func WithTemplateName

func WithTemplateName(templateName string) CommandHandlerOption

Jump to

Keyboard shortcuts

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