Пример #1
0
package cli

import "github.com/jwaldrip/odin/cli/values"

// A Flag represents the state of a flag.
type Flag struct {
	Name     string // name as it appears on command line
	Usage    string // help message
	DefValue string // default value (as text); for usage message

	value values.Value // value as set
}

type boolFlag interface {
	values.Value
	IsBoolValue() bool
}

var noString string
var noValue = values.NewString("", &noString)
var noFlag = &Flag{
	Name:     "",
	Usage:    "",
	DefValue: noValue.String(),
	value:    noValue,
}
Пример #2
0
// DefineStringFlagVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a string variable in which to store the value of the flag.
func (cmd *CLI) DefineStringFlagVar(p *string, name string, value string, usage string) {
	cmd.DefineFlag(values.NewString(value, p), name, usage)
}
Пример #3
0
func (cmd *CLI) assignUnparsedArgs(args []string) {
	for _, arg := range args {
		str := ""
		cmd.unparsedArgs = append(cmd.unparsedArgs, values.NewString(arg, &str))
	}
}