tool

package
v0.0.0-...-4f40efb Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

manages main executable as agglomeration of tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConditionalRun

func ConditionalRun(msg string, def bool, runTrue, runFalse func())

func ConfirmYorN

func ConfirmYorN(msg string, def bool) (bool, error)

func Description

func Description(i Interface) string

func Flags

func Flags(i Interface) *flag.FlagSet

func FlagsWithDoc

func FlagsWithDoc(i Interface, doc string) *flag.FlagSet

func FormatTextTable

func FormatTextTable(borders bool, prefix string, cols []string, rows []map[string]string) string

func ListTools

func ListTools(names []string)

func MyTestCommand

func MyTestCommand(parser FlagParser)

func Name

func Name(i Interface) string

func Names

func Names() (out []string)

gets all tool names

func Register

func Register(r Interface)

func RegisterChild

func RegisterChild(parent string, child Interface)

func Run

func Run()

func RunInterface

func RunInterface(i Interface, args []string)

Types

type CanRun

type CanRun interface {
	Run(args []string)
}

type Command

type Command interface {
	Name() string
	Description() string
	Children() Commands
	Add(Command)
	Run(FlagParser)
}

func NewSetup

func NewSetup(name, desc string) Command

func Wrapper

func Wrapper(name, desc string, f CommandFunc) Command

type CommandFunc

type CommandFunc func(p FlagParser)

type Commands

type Commands []Command

func (Commands) Find

func (c Commands) Find(name string) Command

func (Commands) Len

func (c Commands) Len() int

func (Commands) Less

func (c Commands) Less(i, j int) bool

func (Commands) Swap

func (c Commands) Swap(i, j int)

type FlagParser

type FlagParser func(func(f *flag.FlagSet))

type HasDescription

type HasDescription interface {
	Description() string
}

type HasName

type HasName interface {
	Name() string // no dots before optional comma, description after
}

type Interface

type Interface interface{}

func ForName

func ForName(name string) Interface

gets the tool with given name

func Named

func Named(name string, i RunFunc) Interface

func ToolsForNames

func ToolsForNames(names []string) []Interface

type RunFunc

type RunFunc func(args []string)

func (RunFunc) Run

func (r RunFunc) Run(args []string)

Jump to

Keyboard shortcuts

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