Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b02f1161
Commit
b02f1161
authored
Apr 12, 2018
by
Michael Taufen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update godeps to use latest pflag
parent
cb5f1ad9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
365 additions
and
40 deletions
+365
-40
Godeps.json
Godeps/Godeps.json
+0
-0
Godeps.json
staging/src/k8s.io/api/Godeps/Godeps.json
+2
-2
Godeps.json
...ing/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/apimachinery/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/apiserver/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/client-go/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/code-generator/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/metrics/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/sample-controller/Godeps/Godeps.json
+2
-2
BUILD
vendor/github.com/spf13/pflag/BUILD
+2
-0
bytes.go
vendor/github.com/spf13/pflag/bytes.go
+105
-0
duration_slice.go
vendor/github.com/spf13/pflag/duration_slice.go
+128
-0
flag.go
vendor/github.com/spf13/pflag/flag.go
+82
-16
golangflag.go
vendor/github.com/spf13/pflag/golangflag.go
+4
-0
string_array.go
vendor/github.com/spf13/pflag/string_array.go
+4
-4
string_slice.go
vendor/github.com/spf13/pflag/string_slice.go
+20
-0
No files found.
Godeps/Godeps.json
View file @
b02f1161
This diff is collapsed.
Click to expand it.
staging/src/k8s.io/api/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/api"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -24,7 +24,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"golang.org/x/net/http2"
,
...
...
staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/apiextensions-apiserver"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -584,7 +584,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"github.com/stretchr/testify/assert"
,
...
...
staging/src/k8s.io/apimachinery/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/apimachinery"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -108,7 +108,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"github.com/stretchr/testify/assert"
,
...
...
staging/src/k8s.io/apiserver/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/apiserver"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -560,7 +560,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"github.com/stretchr/testify/assert"
,
...
...
staging/src/k8s.io/client-go/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/client-go"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -152,7 +152,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"github.com/stretchr/testify/assert"
,
...
...
staging/src/k8s.io/code-generator/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/code-generator"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -156,7 +156,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"golang.org/x/net/idna"
,
...
...
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/kube-aggregator"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -268,7 +268,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"github.com/stretchr/testify/assert"
,
...
...
staging/src/k8s.io/metrics/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/metrics"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -64,7 +64,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"golang.org/x/crypto/ssh/terminal"
,
...
...
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/sample-apiserver"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -252,7 +252,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"github.com/ugorji/go/codec"
,
...
...
staging/src/k8s.io/sample-controller/Godeps/Godeps.json
View file @
b02f1161
{
"ImportPath"
:
"k8s.io/sample-controller"
,
"GoVersion"
:
"go1.
9
"
,
"GoVersion"
:
"go1.
10
"
,
"GodepVersion"
:
"v80"
,
"Packages"
:
[
"./..."
...
...
@@ -84,7 +84,7 @@
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"
4c012f6dcd9546820e378d0bdda4d8fc772cdfea
"
"Rev"
:
"
583c0c0531f06d5278b7d917446061adc344b5cd
"
},
{
"ImportPath"
:
"golang.org/x/crypto/ssh/terminal"
,
...
...
vendor/github.com/spf13/pflag/BUILD
View file @
b02f1161
...
...
@@ -5,8 +5,10 @@ go_library(
srcs = [
"bool.go",
"bool_slice.go",
"bytes.go",
"count.go",
"duration.go",
"duration_slice.go",
"flag.go",
"float32.go",
"float64.go",
...
...
vendor/github.com/spf13/pflag/bytes.go
0 → 100644
View file @
b02f1161
package
pflag
import
(
"encoding/hex"
"fmt"
"strings"
)
// BytesHex adapts []byte for use as a flag. Value of flag is HEX encoded
type
bytesHexValue
[]
byte
func
(
bytesHex
bytesHexValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%X"
,
[]
byte
(
bytesHex
))
}
func
(
bytesHex
*
bytesHexValue
)
Set
(
value
string
)
error
{
bin
,
err
:=
hex
.
DecodeString
(
strings
.
TrimSpace
(
value
))
if
err
!=
nil
{
return
err
}
*
bytesHex
=
bin
return
nil
}
func
(
*
bytesHexValue
)
Type
()
string
{
return
"bytesHex"
}
func
newBytesHexValue
(
val
[]
byte
,
p
*
[]
byte
)
*
bytesHexValue
{
*
p
=
val
return
(
*
bytesHexValue
)(
p
)
}
func
bytesHexConv
(
sval
string
)
(
interface
{},
error
)
{
bin
,
err
:=
hex
.
DecodeString
(
sval
)
if
err
==
nil
{
return
bin
,
nil
}
return
nil
,
fmt
.
Errorf
(
"invalid string being converted to Bytes: %s %s"
,
sval
,
err
)
}
// GetBytesHex return the []byte value of a flag with the given name
func
(
f
*
FlagSet
)
GetBytesHex
(
name
string
)
([]
byte
,
error
)
{
val
,
err
:=
f
.
getFlagType
(
name
,
"bytesHex"
,
bytesHexConv
)
if
err
!=
nil
{
return
[]
byte
{},
err
}
return
val
.
([]
byte
),
nil
}
// BytesHexVar defines an []byte flag with specified name, default value, and usage string.
// The argument p points to an []byte variable in which to store the value of the flag.
func
(
f
*
FlagSet
)
BytesHexVar
(
p
*
[]
byte
,
name
string
,
value
[]
byte
,
usage
string
)
{
f
.
VarP
(
newBytesHexValue
(
value
,
p
),
name
,
""
,
usage
)
}
// BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.
func
(
f
*
FlagSet
)
BytesHexVarP
(
p
*
[]
byte
,
name
,
shorthand
string
,
value
[]
byte
,
usage
string
)
{
f
.
VarP
(
newBytesHexValue
(
value
,
p
),
name
,
shorthand
,
usage
)
}
// BytesHexVar defines an []byte flag with specified name, default value, and usage string.
// The argument p points to an []byte variable in which to store the value of the flag.
func
BytesHexVar
(
p
*
[]
byte
,
name
string
,
value
[]
byte
,
usage
string
)
{
CommandLine
.
VarP
(
newBytesHexValue
(
value
,
p
),
name
,
""
,
usage
)
}
// BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.
func
BytesHexVarP
(
p
*
[]
byte
,
name
,
shorthand
string
,
value
[]
byte
,
usage
string
)
{
CommandLine
.
VarP
(
newBytesHexValue
(
value
,
p
),
name
,
shorthand
,
usage
)
}
// BytesHex defines an []byte flag with specified name, default value, and usage string.
// The return value is the address of an []byte variable that stores the value of the flag.
func
(
f
*
FlagSet
)
BytesHex
(
name
string
,
value
[]
byte
,
usage
string
)
*
[]
byte
{
p
:=
new
([]
byte
)
f
.
BytesHexVarP
(
p
,
name
,
""
,
value
,
usage
)
return
p
}
// BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.
func
(
f
*
FlagSet
)
BytesHexP
(
name
,
shorthand
string
,
value
[]
byte
,
usage
string
)
*
[]
byte
{
p
:=
new
([]
byte
)
f
.
BytesHexVarP
(
p
,
name
,
shorthand
,
value
,
usage
)
return
p
}
// BytesHex defines an []byte flag with specified name, default value, and usage string.
// The return value is the address of an []byte variable that stores the value of the flag.
func
BytesHex
(
name
string
,
value
[]
byte
,
usage
string
)
*
[]
byte
{
return
CommandLine
.
BytesHexP
(
name
,
""
,
value
,
usage
)
}
// BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.
func
BytesHexP
(
name
,
shorthand
string
,
value
[]
byte
,
usage
string
)
*
[]
byte
{
return
CommandLine
.
BytesHexP
(
name
,
shorthand
,
value
,
usage
)
}
vendor/github.com/spf13/pflag/duration_slice.go
0 → 100644
View file @
b02f1161
package
pflag
import
(
"fmt"
"strings"
"time"
)
// -- durationSlice Value
type
durationSliceValue
struct
{
value
*
[]
time
.
Duration
changed
bool
}
func
newDurationSliceValue
(
val
[]
time
.
Duration
,
p
*
[]
time
.
Duration
)
*
durationSliceValue
{
dsv
:=
new
(
durationSliceValue
)
dsv
.
value
=
p
*
dsv
.
value
=
val
return
dsv
}
func
(
s
*
durationSliceValue
)
Set
(
val
string
)
error
{
ss
:=
strings
.
Split
(
val
,
","
)
out
:=
make
([]
time
.
Duration
,
len
(
ss
))
for
i
,
d
:=
range
ss
{
var
err
error
out
[
i
],
err
=
time
.
ParseDuration
(
d
)
if
err
!=
nil
{
return
err
}
}
if
!
s
.
changed
{
*
s
.
value
=
out
}
else
{
*
s
.
value
=
append
(
*
s
.
value
,
out
...
)
}
s
.
changed
=
true
return
nil
}
func
(
s
*
durationSliceValue
)
Type
()
string
{
return
"durationSlice"
}
func
(
s
*
durationSliceValue
)
String
()
string
{
out
:=
make
([]
string
,
len
(
*
s
.
value
))
for
i
,
d
:=
range
*
s
.
value
{
out
[
i
]
=
fmt
.
Sprintf
(
"%s"
,
d
)
}
return
"["
+
strings
.
Join
(
out
,
","
)
+
"]"
}
func
durationSliceConv
(
val
string
)
(
interface
{},
error
)
{
val
=
strings
.
Trim
(
val
,
"[]"
)
// Empty string would cause a slice with one (empty) entry
if
len
(
val
)
==
0
{
return
[]
time
.
Duration
{},
nil
}
ss
:=
strings
.
Split
(
val
,
","
)
out
:=
make
([]
time
.
Duration
,
len
(
ss
))
for
i
,
d
:=
range
ss
{
var
err
error
out
[
i
],
err
=
time
.
ParseDuration
(
d
)
if
err
!=
nil
{
return
nil
,
err
}
}
return
out
,
nil
}
// GetDurationSlice returns the []time.Duration value of a flag with the given name
func
(
f
*
FlagSet
)
GetDurationSlice
(
name
string
)
([]
time
.
Duration
,
error
)
{
val
,
err
:=
f
.
getFlagType
(
name
,
"durationSlice"
,
durationSliceConv
)
if
err
!=
nil
{
return
[]
time
.
Duration
{},
err
}
return
val
.
([]
time
.
Duration
),
nil
}
// DurationSliceVar defines a durationSlice flag with specified name, default value, and usage string.
// The argument p points to a []time.Duration variable in which to store the value of the flag.
func
(
f
*
FlagSet
)
DurationSliceVar
(
p
*
[]
time
.
Duration
,
name
string
,
value
[]
time
.
Duration
,
usage
string
)
{
f
.
VarP
(
newDurationSliceValue
(
value
,
p
),
name
,
""
,
usage
)
}
// DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.
func
(
f
*
FlagSet
)
DurationSliceVarP
(
p
*
[]
time
.
Duration
,
name
,
shorthand
string
,
value
[]
time
.
Duration
,
usage
string
)
{
f
.
VarP
(
newDurationSliceValue
(
value
,
p
),
name
,
shorthand
,
usage
)
}
// DurationSliceVar defines a duration[] flag with specified name, default value, and usage string.
// The argument p points to a duration[] variable in which to store the value of the flag.
func
DurationSliceVar
(
p
*
[]
time
.
Duration
,
name
string
,
value
[]
time
.
Duration
,
usage
string
)
{
CommandLine
.
VarP
(
newDurationSliceValue
(
value
,
p
),
name
,
""
,
usage
)
}
// DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.
func
DurationSliceVarP
(
p
*
[]
time
.
Duration
,
name
,
shorthand
string
,
value
[]
time
.
Duration
,
usage
string
)
{
CommandLine
.
VarP
(
newDurationSliceValue
(
value
,
p
),
name
,
shorthand
,
usage
)
}
// DurationSlice defines a []time.Duration flag with specified name, default value, and usage string.
// The return value is the address of a []time.Duration variable that stores the value of the flag.
func
(
f
*
FlagSet
)
DurationSlice
(
name
string
,
value
[]
time
.
Duration
,
usage
string
)
*
[]
time
.
Duration
{
p
:=
[]
time
.
Duration
{}
f
.
DurationSliceVarP
(
&
p
,
name
,
""
,
value
,
usage
)
return
&
p
}
// DurationSliceP is like DurationSlice, but accepts a shorthand letter that can be used after a single dash.
func
(
f
*
FlagSet
)
DurationSliceP
(
name
,
shorthand
string
,
value
[]
time
.
Duration
,
usage
string
)
*
[]
time
.
Duration
{
p
:=
[]
time
.
Duration
{}
f
.
DurationSliceVarP
(
&
p
,
name
,
shorthand
,
value
,
usage
)
return
&
p
}
// DurationSlice defines a []time.Duration flag with specified name, default value, and usage string.
// The return value is the address of a []time.Duration variable that stores the value of the flag.
func
DurationSlice
(
name
string
,
value
[]
time
.
Duration
,
usage
string
)
*
[]
time
.
Duration
{
return
CommandLine
.
DurationSliceP
(
name
,
""
,
value
,
usage
)
}
// DurationSliceP is like DurationSlice, but accepts a shorthand letter that can be used after a single dash.
func
DurationSliceP
(
name
,
shorthand
string
,
value
[]
time
.
Duration
,
usage
string
)
*
[]
time
.
Duration
{
return
CommandLine
.
DurationSliceP
(
name
,
shorthand
,
value
,
usage
)
}
vendor/github.com/spf13/pflag/flag.go
View file @
b02f1161
...
...
@@ -101,6 +101,7 @@ package pflag
import
(
"bytes"
"errors"
goflag
"flag"
"fmt"
"io"
"os"
...
...
@@ -123,6 +124,12 @@ const (
PanicOnError
)
// ParseErrorsWhitelist defines the parsing errors that can be ignored
type
ParseErrorsWhitelist
struct
{
// UnknownFlags will ignore unknown flags errors and continue parsing rest of the flags
UnknownFlags
bool
}
// NormalizedName is a flag name that has been normalized according to rules
// for the FlagSet (e.g. making '-' and '_' equivalent).
type
NormalizedName
string
...
...
@@ -138,6 +145,9 @@ type FlagSet struct {
// help/usage messages.
SortFlags
bool
// ParseErrorsWhitelist is used to configure a whitelist of errors
ParseErrorsWhitelist
ParseErrorsWhitelist
name
string
parsed
bool
actual
map
[
NormalizedName
]
*
Flag
...
...
@@ -153,6 +163,8 @@ type FlagSet struct {
output
io
.
Writer
// nil means stderr; use out() accessor
interspersed
bool
// allow interspersed option/non-option args
normalizeNameFunc
func
(
f
*
FlagSet
,
name
string
)
NormalizedName
addedGoFlagSets
[]
*
goflag
.
FlagSet
}
// A Flag represents the state of a flag.
...
...
@@ -267,16 +279,16 @@ func (f *FlagSet) VisitAll(fn func(*Flag)) {
}
}
// HasFlags returns a bool to indicate if the FlagSet has any flags defin
i
ed.
// HasFlags returns a bool to indicate if the FlagSet has any flags defined.
func
(
f
*
FlagSet
)
HasFlags
()
bool
{
return
len
(
f
.
formal
)
>
0
}
// HasAvailableFlags returns a bool to indicate if the FlagSet has any flags
//
definied that are not hidden or deprecated
.
//
that are not hidden
.
func
(
f
*
FlagSet
)
HasAvailableFlags
()
bool
{
for
_
,
flag
:=
range
f
.
formal
{
if
!
flag
.
Hidden
&&
len
(
flag
.
Deprecated
)
==
0
{
if
!
flag
.
Hidden
{
return
true
}
}
...
...
@@ -386,6 +398,7 @@ func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error {
return
fmt
.
Errorf
(
"deprecated message for flag %q must be set"
,
name
)
}
flag
.
Deprecated
=
usageMessage
flag
.
Hidden
=
true
return
nil
}
...
...
@@ -586,11 +599,14 @@ func wrapN(i, slop int, s string) (string, string) {
return
s
,
""
}
w
:=
strings
.
LastIndexAny
(
s
[
:
i
],
"
\t
"
)
w
:=
strings
.
LastIndexAny
(
s
[
:
i
],
"
\t
\n
"
)
if
w
<=
0
{
return
s
,
""
}
nlPos
:=
strings
.
LastIndex
(
s
[
:
i
],
"
\n
"
)
if
nlPos
>
0
&&
nlPos
<
w
{
return
s
[
:
nlPos
],
s
[
nlPos
+
1
:
]
}
return
s
[
:
w
],
s
[
w
+
1
:
]
}
...
...
@@ -599,7 +615,7 @@ func wrapN(i, slop int, s string) (string, string) {
// caller). Pass `w` == 0 to do no wrapping
func
wrap
(
i
,
w
int
,
s
string
)
string
{
if
w
==
0
{
return
s
return
s
trings
.
Replace
(
s
,
"
\n
"
,
"
\n
"
+
strings
.
Repeat
(
" "
,
i
),
-
1
)
}
// space between indent i and end of line width w into which
...
...
@@ -617,7 +633,7 @@ func wrap(i, w int, s string) string {
}
// If still not enough space then don't even try to wrap.
if
wrap
<
24
{
return
s
return
s
trings
.
Replace
(
s
,
"
\n
"
,
r
,
-
1
)
}
// Try to avoid short orphan words on the final line, by
...
...
@@ -629,14 +645,14 @@ func wrap(i, w int, s string) string {
// Handle first line, which is indented by the caller (or the
// special case above)
l
,
s
=
wrapN
(
wrap
,
slop
,
s
)
r
=
r
+
l
r
=
r
+
strings
.
Replace
(
l
,
"
\n
"
,
"
\n
"
+
strings
.
Repeat
(
" "
,
i
),
-
1
)
// Now wrap the rest
for
s
!=
""
{
var
t
string
t
,
s
=
wrapN
(
wrap
,
slop
,
s
)
r
=
r
+
"
\n
"
+
strings
.
Repeat
(
" "
,
i
)
+
t
r
=
r
+
"
\n
"
+
strings
.
Repeat
(
" "
,
i
)
+
strings
.
Replace
(
t
,
"
\n
"
,
"
\n
"
+
strings
.
Repeat
(
" "
,
i
),
-
1
)
}
return
r
...
...
@@ -653,7 +669,7 @@ func (f *FlagSet) FlagUsagesWrapped(cols int) string {
maxlen
:=
0
f
.
VisitAll
(
func
(
flag
*
Flag
)
{
if
flag
.
Deprecated
!=
""
||
flag
.
Hidden
{
if
flag
.
Hidden
{
return
}
...
...
@@ -700,6 +716,9 @@ func (f *FlagSet) FlagUsagesWrapped(cols int) string {
line
+=
fmt
.
Sprintf
(
" (default %s)"
,
flag
.
DefValue
)
}
}
if
len
(
flag
.
Deprecated
)
!=
0
{
line
+=
fmt
.
Sprintf
(
" (DEPRECATED: %s)"
,
flag
.
Deprecated
)
}
lines
=
append
(
lines
,
line
)
})
...
...
@@ -896,6 +915,25 @@ func (f *FlagSet) usage() {
}
}
//--unknown (args will be empty)
//--unknown --next-flag ... (args will be --next-flag ...)
//--unknown arg ... (args will be arg ...)
func
stripUnknownFlagValue
(
args
[]
string
)
[]
string
{
if
len
(
args
)
==
0
{
//--unknown
return
args
}
first
:=
args
[
0
]
if
first
[
0
]
==
'-'
{
//--unknown --next-flag ...
return
args
}
//--unknown arg ... (args will be arg ...)
return
args
[
1
:
]
}
func
(
f
*
FlagSet
)
parseLongArg
(
s
string
,
args
[]
string
,
fn
parseFunc
)
(
a
[]
string
,
err
error
)
{
a
=
args
name
:=
s
[
2
:
]
...
...
@@ -907,13 +945,24 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin
split
:=
strings
.
SplitN
(
name
,
"="
,
2
)
name
=
split
[
0
]
flag
,
exists
:=
f
.
formal
[
f
.
normalizeFlagName
(
name
)]
if
!
exists
{
if
name
==
"help"
{
// special case for nice help message.
switch
{
case
name
==
"help"
:
f
.
usage
()
return
a
,
ErrHelp
case
f
.
ParseErrorsWhitelist
.
UnknownFlags
:
// --unknown=unknownval arg ...
// we do not want to lose arg in this case
if
len
(
split
)
>=
2
{
return
a
,
nil
}
return
stripUnknownFlagValue
(
a
),
nil
default
:
err
=
f
.
failf
(
"unknown flag: --%s"
,
name
)
return
}
err
=
f
.
failf
(
"unknown flag: --%s"
,
name
)
return
}
var
value
string
...
...
@@ -951,13 +1000,25 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse
flag
,
exists
:=
f
.
shorthands
[
c
]
if
!
exists
{
if
c
==
'h'
{
// special case for nice help message.
switch
{
case
c
==
'h'
:
f
.
usage
()
err
=
ErrHelp
return
case
f
.
ParseErrorsWhitelist
.
UnknownFlags
:
// '-f=arg arg ...'
// we do not want to lose arg in this case
if
len
(
shorthands
)
>
2
&&
shorthands
[
1
]
==
'='
{
outShorts
=
""
return
}
outArgs
=
stripUnknownFlagValue
(
outArgs
)
return
default
:
err
=
f
.
failf
(
"unknown shorthand flag: %q in -%s"
,
c
,
shorthands
)
return
}
err
=
f
.
failf
(
"unknown shorthand flag: %q in -%s"
,
c
,
shorthands
)
return
}
var
value
string
...
...
@@ -1044,6 +1105,11 @@ func (f *FlagSet) parseArgs(args []string, fn parseFunc) (err error) {
// are defined and before flags are accessed by the program.
// The return value will be ErrHelp if -help was set but not defined.
func
(
f
*
FlagSet
)
Parse
(
arguments
[]
string
)
error
{
if
f
.
addedGoFlagSets
!=
nil
{
for
_
,
goFlagSet
:=
range
f
.
addedGoFlagSets
{
goFlagSet
.
Parse
(
nil
)
}
}
f
.
parsed
=
true
if
len
(
arguments
)
<
0
{
...
...
vendor/github.com/spf13/pflag/golangflag.go
View file @
b02f1161
...
...
@@ -98,4 +98,8 @@ func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) {
newSet
.
VisitAll
(
func
(
goflag
*
goflag
.
Flag
)
{
f
.
AddGoFlag
(
goflag
)
})
if
f
.
addedGoFlagSets
==
nil
{
f
.
addedGoFlagSets
=
make
([]
*
goflag
.
FlagSet
,
0
)
}
f
.
addedGoFlagSets
=
append
(
f
.
addedGoFlagSets
,
newSet
)
}
vendor/github.com/spf13/pflag/string_array.go
View file @
b02f1161
...
...
@@ -52,7 +52,7 @@ func (f *FlagSet) GetStringArray(name string) ([]string, error) {
// StringArrayVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a []string variable in which to store the values of the multiple flags.
// The value of each argument will not try to be separated by comma
// The value of each argument will not try to be separated by comma
. Use a StringSlice for that.
func
(
f
*
FlagSet
)
StringArrayVar
(
p
*
[]
string
,
name
string
,
value
[]
string
,
usage
string
)
{
f
.
VarP
(
newStringArrayValue
(
value
,
p
),
name
,
""
,
usage
)
}
...
...
@@ -64,7 +64,7 @@ func (f *FlagSet) StringArrayVarP(p *[]string, name, shorthand string, value []s
// StringArrayVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a []string variable in which to store the value of the flag.
// The value of each argument will not try to be separated by comma
// The value of each argument will not try to be separated by comma
. Use a StringSlice for that.
func
StringArrayVar
(
p
*
[]
string
,
name
string
,
value
[]
string
,
usage
string
)
{
CommandLine
.
VarP
(
newStringArrayValue
(
value
,
p
),
name
,
""
,
usage
)
}
...
...
@@ -76,7 +76,7 @@ func StringArrayVarP(p *[]string, name, shorthand string, value []string, usage
// StringArray defines a string flag with specified name, default value, and usage string.
// The return value is the address of a []string variable that stores the value of the flag.
// The value of each argument will not try to be separated by comma
// The value of each argument will not try to be separated by comma
. Use a StringSlice for that.
func
(
f
*
FlagSet
)
StringArray
(
name
string
,
value
[]
string
,
usage
string
)
*
[]
string
{
p
:=
[]
string
{}
f
.
StringArrayVarP
(
&
p
,
name
,
""
,
value
,
usage
)
...
...
@@ -92,7 +92,7 @@ func (f *FlagSet) StringArrayP(name, shorthand string, value []string, usage str
// StringArray defines a string flag with specified name, default value, and usage string.
// The return value is the address of a []string variable that stores the value of the flag.
// The value of each argument will not try to be separated by comma
// The value of each argument will not try to be separated by comma
. Use a StringSlice for that.
func
StringArray
(
name
string
,
value
[]
string
,
usage
string
)
*
[]
string
{
return
CommandLine
.
StringArrayP
(
name
,
""
,
value
,
usage
)
}
...
...
vendor/github.com/spf13/pflag/string_slice.go
View file @
b02f1161
...
...
@@ -82,6 +82,11 @@ func (f *FlagSet) GetStringSlice(name string) ([]string, error) {
// StringSliceVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a []string variable in which to store the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
// --ss="v1,v2" -ss="v3"
// will result in
// []string{"v1", "v2", "v3"}
func
(
f
*
FlagSet
)
StringSliceVar
(
p
*
[]
string
,
name
string
,
value
[]
string
,
usage
string
)
{
f
.
VarP
(
newStringSliceValue
(
value
,
p
),
name
,
""
,
usage
)
}
...
...
@@ -93,6 +98,11 @@ func (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []s
// StringSliceVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a []string variable in which to store the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
// --ss="v1,v2" -ss="v3"
// will result in
// []string{"v1", "v2", "v3"}
func
StringSliceVar
(
p
*
[]
string
,
name
string
,
value
[]
string
,
usage
string
)
{
CommandLine
.
VarP
(
newStringSliceValue
(
value
,
p
),
name
,
""
,
usage
)
}
...
...
@@ -104,6 +114,11 @@ func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage
// StringSlice defines a string flag with specified name, default value, and usage string.
// The return value is the address of a []string variable that stores the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
// --ss="v1,v2" -ss="v3"
// will result in
// []string{"v1", "v2", "v3"}
func
(
f
*
FlagSet
)
StringSlice
(
name
string
,
value
[]
string
,
usage
string
)
*
[]
string
{
p
:=
[]
string
{}
f
.
StringSliceVarP
(
&
p
,
name
,
""
,
value
,
usage
)
...
...
@@ -119,6 +134,11 @@ func (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage str
// StringSlice defines a string flag with specified name, default value, and usage string.
// The return value is the address of a []string variable that stores the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
// --ss="v1,v2" -ss="v3"
// will result in
// []string{"v1", "v2", "v3"}
func
StringSlice
(
name
string
,
value
[]
string
,
usage
string
)
*
[]
string
{
return
CommandLine
.
StringSliceP
(
name
,
""
,
value
,
usage
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment