Debian Codegraph @

enum.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 "errorsscip-go gomod github.com/golang/go/src go1.13 errors/"
8
9 type enumValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue# string
10
11 var enumValuesscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValues. = make(map[*enumValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#]map[string]struct{})
12
13 func (s *enumValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#) Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#Set().(value string, opt Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option#) error {
14 es, ok := enumValuesscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValues.[s]
15 if !ok || es == nil {
16 return errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Newscip-go gomod github.com/golang/go/src go1.13 errors/New().("this option has no values")
17 }
18 if _, ok := es[value]; !ok {
19 return errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Newscip-go gomod github.com/golang/go/src go1.13 errors/New().("invalid value: " + value)
20 }
21 *s = enumValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#(value)
22 return nil
23 }
24
25 func (s *enumValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#) Stringscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#String().() string {
26 return string(*s)
27 }
28
29 // Enum creates an option that can only be set to one of the enumerated strings
30 // passed in values. Passing nil or an empty slice results in an option that
31 // will always fail.
32 func Enumscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Enum().(name rune, values []string, helpvalue ...string) *string {
33 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..Enumscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Enum().(name, values, helpvalue...)
34 }
35
36 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Enumscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Enum().(name rune, values []string, helpvalue ...string) *string {
37 var p string
38 s.EnumVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumVarLong().(&p, "", name, values, helpvalue...)
39 return &p
40 }
41
42 func EnumLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/EnumLong().(name string, short rune, values []string, helpvalue ...string) *string {
43 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..EnumLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumLong().(name, short, values, helpvalue...)
44 }
45
46 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) EnumLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumLong().(name string, short rune, values []string, helpvalue ...string) *string {
47 var p string
48 s.EnumVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumVarLong().(&p, name, short, values, helpvalue...)
49 return &p
50 }
51
52 // EnumVar creates an enum option that defaults to the starting value of *p.
53 // If *p is not found in values then a reset of this option will fail.
54 func EnumVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/EnumVar().(p *string, name rune, values []string, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
55 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..EnumVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumVar().(p, name, values, helpvalue...)
56 }
57
58 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) EnumVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumVar().(p *string, name rune, values []string, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
59 return s.EnumVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumVarLong().(p, "", name, values, helpvalue...)
60 }
61
62 func EnumVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/EnumVarLong().(p *string, name string, short rune, values []string, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
63 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..EnumVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumVarLong().(p, name, short, values, helpvalue...)
64 }
65
66 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) EnumVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#EnumVarLong().(p *string, name string, short rune, values []string, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
67 m := make(map[string]struct{})
68 for _, v := range values {
69 m[v] = struct{}{}
70 }
71 enumValuesscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValues.[(*enumValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#)(p)] = m
72 return s.VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().((*enumValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumValue#)(p), name, short, helpvalue...)
73 }