Debian Codegraph @

counter.go

raw symbols SCIP
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 counterValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/counterValue# int
13
14 func (b *counterValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/counterValue#) Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/counterValue#Set().(value string, opt Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option#) error {
15 if value == "" {
16 *b++
17 } else {
18 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, strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.IntSizescip-go gomod github.com/golang/go/src go1.13 strconv/IntSize.)
19 if err != nil {
20 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 {
21 switch e.Errscip-go gomod github.com/golang/go/src go1.13 strconv/NumError#Err. {
22 case strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.ErrRangescip-go gomod github.com/golang/go/src go1.13 strconv/ErrRange.:
23 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)
24 case strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.ErrSyntaxscip-go gomod github.com/golang/go/src go1.13 strconv/ErrSyntax.:
25 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)
26 }
27 }
28 return err
29 }
30 *b = counterValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/counterValue#(v)
31 }
32 return nil
33 }
34
35 func (b *counterValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/counterValue#) Stringscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/counterValue#String().() string {
36 return strconvscip-go gomod github.com/golang/go/src go1.13 strconv/.Itoascip-go gomod github.com/golang/go/src go1.13 strconv/Itoa().(int(*b))
37 }
38
39 // Counter creates a counting flag stored as an int. Each time the option
40 // is seen while parsing the value is incremented. The value of the counter
41 // may be explicitly set by using the long form:
42 //
43 // --counter=5
44 // --c=5
45 //
46 // Further instances of the option will increment from the set value.
47 func Counterscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Counter().(name rune, helpvalue ...string) *int {
48 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..Counterscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Counter().(name, helpvalue...)
49 }
50
51 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Counterscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Counter().(name rune, helpvalue ...string) *int {
52 var p int
53 s.CounterVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterVarLong().(&p, "", name, helpvalue...)
54 return &p
55 }
56
57 func CounterLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CounterLong().(name string, short rune, helpvalue ...string) *int {
58 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..CounterLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterLong().(name, short, helpvalue...)
59 }
60
61 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) CounterLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterLong().(name string, short rune, helpvalue ...string) *int {
62 var p int
63 s.CounterVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterVarLong().(&p, name, short, helpvalue...)
64 return &p
65 }
66
67 func CounterVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CounterVar().(p *int, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
68 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..CounterVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterVar().(p, name, helpvalue...)
69 }
70
71 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) CounterVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterVar().(p *int, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
72 return s.CounterVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterVarLong().(p, "", name, helpvalue...)
73 }
74
75 func CounterVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CounterVarLong().(p *int, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
76 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..CounterVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterVarLong().(p, name, short, helpvalue...)
77 }
78
79 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) CounterVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#CounterVarLong().(p *int, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
80 return s.VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().((*counterValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/counterValue#)(p), name, short, helpvalue...).SetFlagscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option#SetFlag.()
81 }