option.go 826 Bytes
Newer Older
Matt Bell's avatar
Matt Bell committed
1 2 3 4
package commands

import "reflect"

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
5
// Types of Command options
Matt Bell's avatar
Matt Bell committed
6
const (
Matt Bell's avatar
Matt Bell committed
7 8 9 10
	Invalid = reflect.Invalid
	Bool    = reflect.Bool
	Int     = reflect.Int
	Uint    = reflect.Uint
11
	Float   = reflect.Float64
Matt Bell's avatar
Matt Bell committed
12
	String  = reflect.String
Matt Bell's avatar
Matt Bell committed
13 14 15 16
)

// Option is used to specify a field that will be provided by a consumer
type Option struct {
Matt Bell's avatar
Matt Bell committed
17 18
	Names []string     // a list of unique names to
	Type  reflect.Kind // value must be this type
19

Matt Bell's avatar
Matt Bell committed
20 21 22
	// TODO: add more features(?):
	//Default interface{} // the default value (ignored if `Required` is true)
	//Required bool       // whether or not the option must be provided
Matt Bell's avatar
Matt Bell committed
23
}
24 25

// options that are used by this package
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
26
var globalOptions = []Option{
Matt Bell's avatar
Matt Bell committed
27
	Option{[]string{"enc", "encoding"}, String},
28
}
Matt Bell's avatar
Matt Bell committed
29

30
// the above array of Options, wrapped in a Command
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
31
var globalCommand = &Command{
Matt Bell's avatar
Matt Bell committed
32
	Options: globalOptions,
33
}