commands

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// The name of the command.
	Name string
	// A short summary of the command.
	Summary string
	// A long description of the command.
	Description string
	// An example of the command used to execute the command.
	Usage string
	// An optional function to include flag definition to the command.
	Flags flags.FlagHandlerFunction
	// The shell handler function to be executed for the command.
	Function shell.HandlerFunction
}

Command allows to define a shell handler compatible with the HelpCommand.

func (*Command) Define

func (command *Command) Define(flagDefiner flags.FlagDefiner)

Define allows the function to define command-line

func (*Command) Execute

func (command *Command) Execute(writer shell.ResponseWriter, request *shell.Request) error

Execute will execute the command function

func (*Command) GetDescription added in v0.7.0

func (command *Command) GetDescription() string

GetDescription returns the long description of the command handler.

func (*Command) GetName added in v0.7.0

func (command *Command) GetName() string

GetName returns the name of the command handler.

func (*Command) GetSummary added in v0.7.0

func (command *Command) GetSummary() string

GetSummary returns the short summary of the command handler.

func (*Command) GetUsage added in v0.7.0

func (command *Command) GetUsage() string

GetUsage returns an example of the command used to execute the command.

type CommandHandler added in v0.7.0

type CommandHandler interface {
	flags.FlagHandler
	shell.Handler
	// GetName returns the name of the command handler.
	GetName() string
	// GetSummary returns the short summary of the command handler.
	GetSummary() string
	// GetDescription returns the long description of the command handler.
	GetDescription() string
	// GetUsage returns an example of the command used to execute the command.
	GetUsage() string
}

CommandHandler describes a shell function handler that can be described by the HelpCommand

type CommandRouter added in v0.7.0

type CommandRouter struct {
	shell.StandardRouter

	// The name of the command.
	Name string
	// A short summary of the command.
	Summary string
	// A long description of the command.
	Description string
	// An example of the command used to execute the command.
	Usage string
}

CommandRouter is a StandardRouter that conforms to the CommandHandler interface. This allows you to define a group of sub commands which are compatible with the HelpCommand function.

func NewCommandRouter added in v0.7.0

func NewCommandRouter(name, summary, description, usage string, setup func(shell.Router)) *CommandRouter

NewCommandRouter creates a new CommandRouter and runs the setup function for the new router.

func (*CommandRouter) GetDescription added in v0.7.0

func (router *CommandRouter) GetDescription() string

GetDescription returns the long description of the command handler.

func (*CommandRouter) GetName added in v0.7.0

func (router *CommandRouter) GetName() string

GetName returns the name of the command handler.

func (*CommandRouter) GetSummary added in v0.7.0

func (router *CommandRouter) GetSummary() string

GetSummary returns the short summary of the command handler.

func (*CommandRouter) GetUsage added in v0.7.0

func (router *CommandRouter) GetUsage() string

GetUsage returns an example of the command used to execute the command.

type HelpCommand

type HelpCommand struct {
	// The command string that could be used to execute the help command
	// and display a usage example as part of the help command output.
	//
	// If the intention is to only use the help flags, then this could
	// be left empty to omit the usage example.
	Usage string
}

HelpCommand allows for basic output of command metadata.

func (*HelpCommand) Execute

func (command *HelpCommand) Execute(writer shell.ResponseWriter, request *shell.Request) error

Execute will execute the help command

Jump to

Keyboard shortcuts

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