github.com/WindomZ/go-commander@v1.2.2/context.go (about) 1 package commander 2 3 type Context interface { 4 // _Argv 5 GetArg(index int) string 6 GetArgs(offsets ...int) []string 7 ArgsString() string 8 ArgsStringSeparator(sep string, offsets ...int) string 9 // DocoptMap 10 Map() map[string]interface{} 11 Get(key string) interface{} 12 Contain(key string) bool 13 GetString(key string) (string, bool) 14 MustString(key string) string 15 GetStrings(key string) ([]string, bool) 16 MustStrings(key string) []string 17 GetBool(key string) (bool, bool) 18 MustBool(key string) bool 19 GetInt64(key string) (int64, bool) 20 MustInt64(key string) int64 21 GetInt(key string) (int, bool) 22 MustInt(key string) int 23 GetFloat64(key string) (float64, bool) 24 MustFloat64(key string) float64 25 GetFloat(key string) (float32, bool) 26 MustFloat(key string) float32 27 } 28 29 // _Context 30 type _Context struct { 31 _Argv `json:"argv"` 32 DocoptMap `json:"docopt"` 33 } 34 35 func newContext(args []string, d DocoptMap) *_Context { 36 return &_Context{ 37 _Argv: newArgv(args), 38 DocoptMap: d, 39 } 40 } 41 42 func (c _Context) Contain(key string) bool { 43 return c.DocoptMap.Contain(key) 44 }