Debian Codegraph @

var.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 "runtimescip-go gomod github.com/golang/go/src go1.13 runtime/"
10 )
11
12 // Value is the interface to the dynamic value stored in a flag. (The default
13 // value is represented as a string.) Set is passed the string to set the
14 // value to as well as the Option that is being processed.
15 type Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value# interface {
16 Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value#Set.(string, Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option#) error
17 Stringscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value#String.() string
18 }
19
20 // Var creates an option of the specified name. The type and value of the option
21 // are represented by the first argument, of type Value, which typically holds a
22 // user-defined implementation of Value. All options are ultimately created
23 // as a Var.
24 func Varscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Var().(p Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value#, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
25 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().(p, "", name, helpvalue...)
26 }
27
28 func VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/VarLong().(p Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value#, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
29 return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().(p, name, short, helpvalue...)
30 }
31
32 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Varscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#Var().(p Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value#, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
33 return s.VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().(p, "", name, helpvalue...)
34 }
35
36 func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().(p Valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value#, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# {
37 opt := &optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#{
38 shortscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#short.: short,
39 longscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#long.: name,
40 valuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#value.: p,
41 defvalscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#defval.: p.Stringscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Value#String.(),
42 }
43
44 switch len(helpvalue) {
45 case 2:
46 opt.namescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#name. = helpvalue[1]
47 fallthrough
48 case 1:
49 opt.helpscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#help. = helpvalue[0]
50 case 0:
51 default:
52 panic("Too many strings for String helpvalue")
53 }
54 if _, file, line, ok := runtimescip-go gomod github.com/golang/go/src go1.13 runtime/.Callerscip-go gomod github.com/golang/go/src go1.13 runtime/Caller().(1); ok {
55 opt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#where. = fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("%s:%d", file, line)
56 }
57 if opt.shortscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#short. == 0 && opt.longscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#long. == "" {
58 fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.13 fmt/Fprint().(stderrscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/stderr., opt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/option#where.+": no short or long option given")
59 exitscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/exit.(1)
60 }
61 s.AddOptionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#AddOption().(opt)
62 return opt
63 }