extpoints

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2017 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandProviders

func CommandProviders() map[string]CommandProvider

CommandProviders returns a mapping from name to registered CommandProvider.

func Register

func Register(name string, provider CommandProvider)

Register will register a CommandProvider for a given name.

Types

type CommandProvider

type CommandProvider interface {
	// Config options supported by this CommandProvider
	ConfigOptions() map[string]ConfigOption
	// Summary returns a one-line description of what this command is for.
	Summary() string
	// Usage returns the docopt usage string, used to parse arguments.
	Usage() string
	// Execute is called with parsed docopt result in Context
	Execute(context Context) bool
}

CommandProvider is implemented by anyone who wishes to provide a command line command that the cli should support.

type ConfigOption

type ConfigOption struct {
	Description string      // Description of the config option
	Default     interface{} // Default value
	Env         string      // Environment variable to attempt to load from (optional)
	Parse       bool        // True, if string input should be parsed as JSON
	Validate    func(value interface{}) error
}

A ConfigOption is something with a default value and a validator. Only requirement is that values are JSON structures.

type Context

type Context struct {
	// Command line arguments parsed with docopt
	Arguments map[string]interface{}
	// Globally configured taskcluster credentials (nil, if none are available)
	Credentials *client.Credentials
	// Config keys matching declared ConfigOptions
	Config map[string]interface{}
}

Context given to a CommandProvider.Execute

Jump to

Keyboard shortcuts

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