Remove unused return value from PopValueInto.

This commit is contained in:
Alec Thomas
2019-06-21 10:07:24 +10:00
parent 9d0bd59611
commit 1076f5ee1f
4 changed files with 19 additions and 19 deletions
+9 -9
View File
@@ -196,7 +196,7 @@ func (r *Registry) RegisterDefaults() *Registry {
RegisterKind(reflect.Float32, floatDecoder(32)). RegisterKind(reflect.Float32, floatDecoder(32)).
RegisterKind(reflect.Float64, floatDecoder(64)). RegisterKind(reflect.Float64, floatDecoder(64)).
RegisterKind(reflect.String, MapperFunc(func(ctx *DecodeContext, target reflect.Value) error { RegisterKind(reflect.String, MapperFunc(func(ctx *DecodeContext, target reflect.Value) error {
_, err := ctx.Scan.PopValueInto("string", target.Addr().Interface()) err := ctx.Scan.PopValueInto("string", target.Addr().Interface())
return err return err
})). })).
RegisterKind(reflect.Bool, boolMapper{}). RegisterKind(reflect.Bool, boolMapper{}).
@@ -235,7 +235,7 @@ func (boolMapper) IsBool() bool { return true }
func durationDecoder() MapperFunc { func durationDecoder() MapperFunc {
return func(ctx *DecodeContext, target reflect.Value) error { return func(ctx *DecodeContext, target reflect.Value) error {
var value string var value string
if _, err := ctx.Scan.PopValueInto("duration", &value); err != nil { if err := ctx.Scan.PopValueInto("duration", &value); err != nil {
return err return err
} }
r, err := time.ParseDuration(value) r, err := time.ParseDuration(value)
@@ -254,7 +254,7 @@ func timeDecoder() MapperFunc {
format = ctx.Value.Format format = ctx.Value.Format
} }
var value string var value string
if _, err := ctx.Scan.PopValueInto("time", &value); err != nil { if err := ctx.Scan.PopValueInto("time", &value); err != nil {
return err return err
} }
t, err := time.Parse(format, value) t, err := time.Parse(format, value)
@@ -388,7 +388,7 @@ func mapDecoder(r *Registry) MapperFunc {
} }
for !childScanner.Peek().IsEOL() { for !childScanner.Peek().IsEOL() {
var token string var token string
_, err := childScanner.PopValueInto("map", &token) err := childScanner.PopValueInto("map", &token)
if err != nil { if err != nil {
return err return err
} }
@@ -478,7 +478,7 @@ func pathMapper(r *Registry) MapperFunc {
return errors.Errorf("\"path\" type must be applied to a string not %s", target.Type()) return errors.Errorf("\"path\" type must be applied to a string not %s", target.Type())
} }
var path string var path string
_, err := ctx.Scan.PopValueInto("file", &path) err := ctx.Scan.PopValueInto("file", &path)
if err != nil { if err != nil {
return err return err
} }
@@ -497,7 +497,7 @@ func existingFileMapper(r *Registry) MapperFunc {
return errors.Errorf("\"existingfile\" type must be applied to a string not %s", target.Type()) return errors.Errorf("\"existingfile\" type must be applied to a string not %s", target.Type())
} }
var path string var path string
_, err := ctx.Scan.PopValueInto("file", &path) err := ctx.Scan.PopValueInto("file", &path)
if err != nil { if err != nil {
return err return err
} }
@@ -523,7 +523,7 @@ func existingDirMapper(r *Registry) MapperFunc {
return errors.Errorf("\"existingdir\" must be applied to a string not %s", target.Type()) return errors.Errorf("\"existingdir\" must be applied to a string not %s", target.Type())
} }
var path string var path string
_, err := ctx.Scan.PopValueInto("file", &path) err := ctx.Scan.PopValueInto("file", &path)
if err != nil { if err != nil {
return err return err
} }
@@ -543,7 +543,7 @@ func existingDirMapper(r *Registry) MapperFunc {
func urlMapper() MapperFunc { func urlMapper() MapperFunc {
return func(ctx *DecodeContext, target reflect.Value) error { return func(ctx *DecodeContext, target reflect.Value) error {
var urlStr string var urlStr string
_, err := ctx.Scan.PopValueInto("url", &urlStr) err := ctx.Scan.PopValueInto("url", &urlStr)
if err != nil { if err != nil {
return err return err
} }
@@ -601,7 +601,7 @@ type FileContentFlag []byte
func (f *FileContentFlag) Decode(ctx *DecodeContext) error { // nolint: golint func (f *FileContentFlag) Decode(ctx *DecodeContext) error { // nolint: golint
var filename string var filename string
_, err := ctx.Scan.PopValueInto("filename", &filename) err := ctx.Scan.PopValueInto("filename", &filename)
if err != nil { if err != nil {
return err return err
} }
+1 -1
View File
@@ -140,7 +140,7 @@ type mappedValue struct {
} }
func (m *mappedValue) Decode(ctx *kong.DecodeContext) error { func (m *mappedValue) Decode(ctx *kong.DecodeContext) error {
_, err := ctx.Scan.PopValueInto("mapped", &m.decoded) err := ctx.Scan.PopValueInto("mapped", &m.decoded)
return err return err
} }
+1 -1
View File
@@ -123,7 +123,7 @@ type testUppercaseMapper struct{}
func (testUppercaseMapper) Decode(ctx *kong.DecodeContext, target reflect.Value) error { func (testUppercaseMapper) Decode(ctx *kong.DecodeContext, target reflect.Value) error {
var value string var value string
_, err := ctx.Scan.PopValueInto("lowercase", &value) err := ctx.Scan.PopValueInto("lowercase", &value)
if err != nil { if err != nil {
return err return err
} }
+8 -8
View File
@@ -14,11 +14,11 @@ type TokenType int
const ( const (
UntypedToken TokenType = iota UntypedToken TokenType = iota
EOLToken EOLToken
FlagToken // --<flag> FlagToken // --<flag>
FlagValueToken // =<value> FlagValueToken // =<value>
ShortFlagToken // -<short>[<tail] ShortFlagToken // -<short>[<tail]
ShortFlagTailToken // <tail> ShortFlagTailToken // <tail>
PositionalArgumentToken // <arg> PositionalArgumentToken // <arg>
) )
func (t TokenType) String() string { func (t TokenType) String() string {
@@ -156,12 +156,12 @@ func (s *Scanner) PopValue(context string) (Token, error) {
// PopValueInto pops a value token into target or returns an error. // PopValueInto pops a value token into target or returns an error.
// //
// "context" is used to assist the user if the value can not be popped, eg. "expected <context> value but got <type>" // "context" is used to assist the user if the value can not be popped, eg. "expected <context> value but got <type>"
func (s *Scanner) PopValueInto(context string, target interface{}) (Token, error) { func (s *Scanner) PopValueInto(context string, target interface{}) error {
t := s.Pop() t := s.Pop()
if !t.IsValue() { if !t.IsValue() {
return t, errors.Errorf("expected %s value but got %q (%s)", context, t, t.InferredType()) return errors.Errorf("expected %s value but got %q (%s)", context, t, t.InferredType())
} }
return t, jsonTranscode(t.Value, target) return jsonTranscode(t.Value, target)
} }
// PopWhile predicate returns true. // PopWhile predicate returns true.