Documentation ¶
Overview ¶
Command, OptionInfo, help and command execution pattern derived from github.com/constabulary/gb, released under MIT license https://github.com/constabulary/gb/blob/master/LICENSE
Index ¶
- func CmdUsage(toolName string, command Command)
- func ExecCommand(fs *flag.FlagSet, cmd Command, args []string) error
- func PrintCmdHelp(toolName string, command Command)
- func PrintCmdUsage(w io.Writer, toolName string, command Command)
- func RegisterTool(tool *Tool)
- type Command
- type CommandRegistry
- type HasOptionInfo
- type OptionInfo
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecCommand ¶
ExecCommand executes the specified command
func PrintCmdHelp ¶
PrintCmdHelp prints the help details of the specified Command
func PrintCmdUsage ¶
PrintCmdUsage prints the usage details of the specified Command
Types ¶
type Command ¶
type Command interface { HasOptionInfo AddFlags(fs *flag.FlagSet) Exec(args []string) error }
Command represents a command that is executed within flogo project Derived from github.com/constabulary/gb
type CommandRegistry ¶
type CommandRegistry struct {
// contains filtered or unexported fields
}
CommandRegistry is a registry for commands
func NewCommandRegistry ¶
func NewCommandRegistry() *CommandRegistry
NewCommandRegistry creates a new command registry
func (*CommandRegistry) Command ¶
func (r *CommandRegistry) Command(commandName string) (cmd Command, exists bool)
Command gets the specified command
func (*CommandRegistry) CommandOptionInfos ¶
func (r *CommandRegistry) CommandOptionInfos() []*OptionInfo
CommandOptionInfos gets the OptionInfos for all registered commands
func (*CommandRegistry) Commands ¶
func (r *CommandRegistry) Commands() []Command
Commands gets all the registered commands
func (*CommandRegistry) RegisterCommand ¶
func (r *CommandRegistry) RegisterCommand(command Command)
RegisterCommand registers a command
type HasOptionInfo ¶
type HasOptionInfo interface {
OptionInfo() *OptionInfo
}
HasOptionInfo is an interface for an object that has Option Information
type OptionInfo ¶
type OptionInfo struct { // Denotes if tool or command IsTool bool // Name of the tool/command Name string // UsageLine demonstrates how to invoke the tool/command UsageLine string // Short description of tool/command Short string // Description of this tool/command Long string }
OptionInfo is the option information for a command
func GetToolOptionInfos ¶
func GetToolOptionInfos() []*OptionInfo
GetToolOptionInfos gets all the OptionInfos for the registered tools
type Tool ¶
type Tool struct { TplUsage string TplCmdUsage string TplCmdHelp string // contains filtered or unexported fields }
Tool is a
func (*Tool) CmdUsage ¶
CmdUsage prints the usage details of the specified Command and exits with error
func (*Tool) CommandRegistry ¶
func (t *Tool) CommandRegistry() *CommandRegistry
CommandRegistry gets the command registry for the tool
func (*Tool) OptionInfo ¶
func (t *Tool) OptionInfo() *OptionInfo
OptionInfo implements HasOptionInfo
func (*Tool) PrintCmdHelp ¶
PrintCmdHelp prints the help details of the specified Command
func (*Tool) PrintCmdUsage ¶
PrintCmdUsage prints the usage details of the specified Command
func (*Tool) PrintUsage ¶
PrintUsage prints the usage details of the tool