| 1 | // Copyright 2013 Google Inc. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package getoptscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/ |
| 6 | |
| 7 | import ( |
| 8 | "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/" |
| 9 | "strconvscip-go gomod github.com/golang/go/src go1.13 strconv/" |
| 10 | ) |
| 11 | |
| 12 | type int32Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/int32Value# int32 |
| 13 | |
| 14 | func (i *int32Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/int32Value#) Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/int32Value#Set().(value string, opt Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option#) error { |
| 15 | v, err := strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.13 strconv/ParseInt().(value, 0, 32) |
| 16 | if err != nil { |
| 17 | if e, ok := err.(*strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.NumErrorscip-go gomod github.com/golang/go/src go1.13 strconv/NumError#); ok { |
| 18 | switch e.Errscip-go gomod github.com/golang/go/src go1.13 strconv/NumError#Err. { |
| 19 | case strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.ErrRangescip-go gomod github.com/golang/go/src go1.13 strconv/ErrRange.: |
| 20 | err = fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("value out of range: %s", value) |
| 21 | case strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.ErrSyntaxscip-go gomod github.com/golang/go/src go1.13 strconv/ErrSyntax.: |
| 22 | err = fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("not a valid number: %s", value) |
| 23 | } |
| 24 | } |
| 25 | return err |
| 26 | } |
| 27 | *i = int32Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/int32Value#(v) |
| 28 | return nil |
| 29 | } |
| 30 | |
| 31 | func (i *int32Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/int32Value#) Stringscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/int32Value#String().() string { |
| 32 | return strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.13 strconv/FormatInt().(int64(*i), 10) |
| 33 | } |
| 34 | |
| 35 | // Int32 creates an option that parses its value as an int32. |
| 36 | func Int32scip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Int32().(name rune, value int32, helpvalue ...string) *int32 { |
| 37 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..Int32scip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32().(name, value, helpvalue...) |
| 38 | } |
| 39 | |
| 40 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Int32scip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32().(name rune, value int32, helpvalue ...string) *int32 { |
| 41 | return s.Int32Longscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32Long().("", name, value, helpvalue...) |
| 42 | } |
| 43 | |
| 44 | func Int32Longscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Int32Long().(name string, short rune, value int32, helpvalue ...string) *int32 { |
| 45 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..Int32Longscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32Long().(name, short, value, helpvalue...) |
| 46 | } |
| 47 | |
| 48 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Int32Longscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32Long().(name string, short rune, value int32, helpvalue ...string) *int32 { |
| 49 | s.Int32VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32VarLong().(&value, name, short, helpvalue...) |
| 50 | return &value |
| 51 | } |
| 52 | |
| 53 | func Int32Varscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Int32Var().(p *int32, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 54 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..Int32Varscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32Var().(p, name, helpvalue...) |
| 55 | } |
| 56 | |
| 57 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Int32Varscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32Var().(p *int32, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 58 | return s.Int32VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32VarLong().(p, "", name, helpvalue...) |
| 59 | } |
| 60 | |
| 61 | func Int32VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Int32VarLong().(p *int32, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 62 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..Int32VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32VarLong().(p, name, short, helpvalue...) |
| 63 | } |
| 64 | |
| 65 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Int32VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Int32VarLong().(p *int32, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 66 | return s.VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().((*int32Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/int32Value#)(p), name, short, helpvalue...) |
| 67 | } |