Documentation ¶
Overview ¶
This set of routines encapsulates the cli structure, which holds the help text and definitions for a gus cli.
See License for copyright information. Portions of this code are (c) 2012 by the Go Authors. This code has been been adapted for use in GUS and is not the sole work of Charles Gentry.
Index ¶
- func Box(w io.Writer, info string)
- func Help(usageTemplate, cmd string, args []string, commands []*Command)
- func ParseBool(txt string) (rtn bool, err error)
- func PrintStructValue(w io.Writer, substruct interface{})
- func PromptForStructFields(substruct interface{}, helpTemplate string)
- func PromptInteger(w io.Writer, r io.Reader, prompt string) (val int, err error)
- func PromptIntegerDefault(w io.Writer, r io.Reader, prompt string, defaultValue int) int
- func PromptString(w io.Writer, r io.Reader, prompt string) (string, error)
- func PromptStringDefault(w io.Writer, r io.Reader, prompt, defaultValue string) string
- func PromptYesNo(w io.Writer, r io.Reader, prompt string) (bool, error)
- func PromptYesNoDefault(w io.Writer, r io.Reader, prompt string, defaultValue bool) bool
- func RenderTemplate(w io.Writer, text string, data interface{})
- func Usage(usageTemplate string, commands []*Command)
- type Command
- type Helper
- type StructNameList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintStructValue ¶
func PromptForStructFields ¶
func PromptForStructFields(substruct interface{}, helpTemplate string)
func PromptInteger ¶
Simple prompt for interger. Caller can pass buffers or os.Stdin/os.Stdout
func PromptIntegerDefault ¶
Prompt for a integer value but accept a default value if they don't enter anything.
func PromptStringDefault ¶
func PromptYesNo ¶
Simple prompt for yes or no values. Caller can pass buffers or os.Stdin/os.Stdout
func PromptYesNoDefault ¶
Prompt for a yes/no value but accept a default value if they don't enter anything.
func RenderTemplate ¶
RenderTemplate executes the given template text on data, writing the result to w.
Types ¶
type Command ¶
type Command struct { Name string // Run runs the cli. // The args are the arguments after the cli name. Run func(cmd *Command, args []string) // UsageLine is the one-line usage message. UsageLine string // Short is the short description shown in the 'go help' output. Short string // Long is the long message shown in the 'go help <this-cli>' output. Long string // Flag is a set of flags specific to this cli. Flag flag.FlagSet // CustomFlags indicates that the cli will do its own // flag parsing. CustomFlags bool }
A cli is any subcommand, such as createstore (from go source code)