cli

package
v0.1.1-0...-5e7805d Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2015 License: Apache-2.0 Imports: 7 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alias

func Alias(name string, alias string)

func ProcessCommand

func ProcessCommand(h HasFlags) error

func Register

func Register(name string, c Command)

func RegisterCommand

func RegisterCommand(h HasFlags, f *flag.FlagSet)

func Run

func Run(args []string) int

func Walk

func Walk(c interface{}, ifaceType reflect.Type, fn WalkFn) error

Walk recursively walks struct types that implement the specified interface. Fields that implement the specified interface are expected to be pointer values. This allows the function to cache pointer values on a per-type basis. If, during a recursive walk, the same type is encountered twice, the function creates a new value of that type the first time, and reuses that same value the second time.

This function is used to make sure that a hierarchy of flags where multiple structs refer to the `Client` flag will not end up with more than one instance of the actual client. Rather, every struct referring to the `Client` flag will have a pointer to the same underlying `Client` struct.

Types

type Command

type Command interface {
	HasFlags

	Run(f *flag.FlagSet) error
}

type HasFlags

type HasFlags interface {
	// Register may be called more than once and should be idempotent.
	Register(f *flag.FlagSet)

	// Process may be called more than once and should be idempotent.
	Process() error
}

type WalkFn

type WalkFn func(c interface{}) error

Jump to

Keyboard shortcuts

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