mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
Drop caddy from vendor (#700)
* Removed caddy * new stuff * Now need to go get caddy * Duh
This commit is contained in:
21
vendor/github.com/spf13/pflag/.travis.yml
generated
vendored
21
vendor/github.com/spf13/pflag/.travis.yml
generated
vendored
@@ -3,18 +3,19 @@ sudo: false
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.6.3
|
||||
- 1.7.3
|
||||
- tip
|
||||
- 1.7.3
|
||||
- 1.8.1
|
||||
- tip
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- go: tip
|
||||
allow_failures:
|
||||
- go: tip
|
||||
|
||||
install:
|
||||
- go get github.com/golang/lint/golint
|
||||
- export PATH=$GOPATH/bin:$PATH
|
||||
- go install ./...
|
||||
- go get github.com/golang/lint/golint
|
||||
- export PATH=$GOPATH/bin:$PATH
|
||||
- go install ./...
|
||||
|
||||
script:
|
||||
- verify/all.sh -v
|
||||
- go test ./...
|
||||
- verify/all.sh -v
|
||||
- go test ./...
|
||||
|
||||
79
vendor/github.com/spf13/pflag/example_test.go
generated
vendored
79
vendor/github.com/spf13/pflag/example_test.go
generated
vendored
@@ -2,76 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// These examples demonstrate more intricate uses of the flag package.
|
||||
package pflag_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
flag "github.com/spf13/pflag"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
// Example 1: A single string flag called "species" with default value "gopher".
|
||||
var species = flag.String("species", "gopher", "the species we are studying")
|
||||
func ExampleShorthandLookup() {
|
||||
name := "verbose"
|
||||
short := name[:1]
|
||||
|
||||
// Example 2: A flag with a shorthand letter.
|
||||
var gopherType = flag.StringP("gopher_type", "g", "pocket", "the variety of gopher")
|
||||
pflag.BoolP(name, short, false, "verbose output")
|
||||
|
||||
// Example 3: A user-defined flag type, a slice of durations.
|
||||
type interval []time.Duration
|
||||
// len(short) must be == 1
|
||||
flag := pflag.ShorthandLookup(short)
|
||||
|
||||
// String is the method to format the flag's value, part of the flag.Value interface.
|
||||
// The String method's output will be used in diagnostics.
|
||||
func (i *interval) String() string {
|
||||
return fmt.Sprint(*i)
|
||||
fmt.Println(flag.Name)
|
||||
}
|
||||
|
||||
func (i *interval) Type() string {
|
||||
return "interval"
|
||||
}
|
||||
|
||||
// Set is the method to set the flag value, part of the flag.Value interface.
|
||||
// Set's argument is a string to be parsed to set the flag.
|
||||
// It's a comma-separated list, so we split it.
|
||||
func (i *interval) Set(value string) error {
|
||||
// If we wanted to allow the flag to be set multiple times,
|
||||
// accumulating values, we would delete this if statement.
|
||||
// That would permit usages such as
|
||||
// -deltaT 10s -deltaT 15s
|
||||
// and other combinations.
|
||||
if len(*i) > 0 {
|
||||
return errors.New("interval flag already set")
|
||||
}
|
||||
for _, dt := range strings.Split(value, ",") {
|
||||
duration, err := time.ParseDuration(dt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*i = append(*i, duration)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Define a flag to accumulate durations. Because it has a special type,
|
||||
// we need to use the Var function and therefore create the flag during
|
||||
// init.
|
||||
|
||||
var intervalFlag interval
|
||||
|
||||
func init() {
|
||||
// Tie the command-line flag to the intervalFlag variable and
|
||||
// set a usage message.
|
||||
flag.Var(&intervalFlag, "deltaT", "comma-separated list of intervals to use between events")
|
||||
}
|
||||
|
||||
func Example() {
|
||||
// All the interesting pieces are with the variables declared above, but
|
||||
// to enable the flag package to see the flags defined there, one must
|
||||
// execute, typically at the start of main (not init!):
|
||||
// flag.Parse()
|
||||
// We don't run it here because this is not a main function and
|
||||
// the testing suite has already parsed the flags.
|
||||
func ExampleFlagSet_ShorthandLookup() {
|
||||
name := "verbose"
|
||||
short := name[:1]
|
||||
|
||||
fs := pflag.NewFlagSet("Example", pflag.ContinueOnError)
|
||||
fs.BoolP(name, short, false, "verbose output")
|
||||
|
||||
// len(short) must be == 1
|
||||
flag := fs.ShorthandLookup(short)
|
||||
|
||||
fmt.Println(flag.Name)
|
||||
}
|
||||
|
||||
23
vendor/github.com/spf13/pflag/flag.go
generated
vendored
23
vendor/github.com/spf13/pflag/flag.go
generated
vendored
@@ -319,6 +319,22 @@ func (f *FlagSet) Lookup(name string) *Flag {
|
||||
return f.lookup(f.normalizeFlagName(name))
|
||||
}
|
||||
|
||||
// ShorthandLookup returns the Flag structure of the short handed flag,
|
||||
// returning nil if none exists.
|
||||
// It panics, if len(name) > 1.
|
||||
func (f *FlagSet) ShorthandLookup(name string) *Flag {
|
||||
if name == "" {
|
||||
return nil
|
||||
}
|
||||
if len(name) > 1 {
|
||||
msg := fmt.Sprintf("can not look up shorthand which is more than one ASCII character: %q", name)
|
||||
fmt.Fprintf(f.out(), msg)
|
||||
panic(msg)
|
||||
}
|
||||
c := name[0]
|
||||
return f.shorthands[c]
|
||||
}
|
||||
|
||||
// lookup returns the Flag structure of the named flag, returning nil if none exists.
|
||||
func (f *FlagSet) lookup(name NormalizedName) *Flag {
|
||||
return f.formal[name]
|
||||
@@ -399,6 +415,12 @@ func Lookup(name string) *Flag {
|
||||
return CommandLine.Lookup(name)
|
||||
}
|
||||
|
||||
// ShorthandLookup returns the Flag structure of the short handed flag,
|
||||
// returning nil if none exists.
|
||||
func ShorthandLookup(name string) *Flag {
|
||||
return CommandLine.ShorthandLookup(name)
|
||||
}
|
||||
|
||||
// Set sets the value of the named flag.
|
||||
func (f *FlagSet) Set(name, value string) error {
|
||||
normalName := f.normalizeFlagName(name)
|
||||
@@ -766,7 +788,6 @@ func (f *FlagSet) VarP(value Value, name, shorthand, usage string) {
|
||||
|
||||
// AddFlag will add the flag to the FlagSet
|
||||
func (f *FlagSet) AddFlag(flag *Flag) {
|
||||
// Call normalizeFlagName function only once
|
||||
normalizedFlagName := f.normalizeFlagName(flag.Name)
|
||||
|
||||
_, alreadyThere := f.formal[normalizedFlagName]
|
||||
|
||||
39
vendor/github.com/spf13/pflag/flag_test.go
generated
vendored
39
vendor/github.com/spf13/pflag/flag_test.go
generated
vendored
@@ -446,6 +446,42 @@ func TestShorthand(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShorthandLookup(t *testing.T) {
|
||||
f := NewFlagSet("shorthand", ContinueOnError)
|
||||
if f.Parsed() {
|
||||
t.Error("f.Parse() = true before Parse")
|
||||
}
|
||||
f.BoolP("boola", "a", false, "bool value")
|
||||
f.BoolP("boolb", "b", false, "bool2 value")
|
||||
args := []string{
|
||||
"-ab",
|
||||
}
|
||||
f.SetOutput(ioutil.Discard)
|
||||
if err := f.Parse(args); err != nil {
|
||||
t.Error("expected no error, got ", err)
|
||||
}
|
||||
if !f.Parsed() {
|
||||
t.Error("f.Parse() = false after Parse")
|
||||
}
|
||||
flag := f.ShorthandLookup("a")
|
||||
if flag == nil {
|
||||
t.Errorf("f.ShorthandLookup(\"a\") returned nil")
|
||||
}
|
||||
if flag.Name != "boola" {
|
||||
t.Errorf("f.ShorthandLookup(\"a\") found %q instead of \"boola\"", flag.Name)
|
||||
}
|
||||
flag = f.ShorthandLookup("")
|
||||
if flag != nil {
|
||||
t.Errorf("f.ShorthandLookup(\"\") did not return nil")
|
||||
}
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
flag = f.ShorthandLookup("ab")
|
||||
// should NEVER get here. lookup should panic. defer'd func should recover it.
|
||||
t.Errorf("f.ShorthandLookup(\"ab\") did not panic")
|
||||
}
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
ResetForTesting(func() { t.Error("bad parse") })
|
||||
testParse(GetCommandLine(), t)
|
||||
@@ -936,6 +972,7 @@ const defaultOutput = ` --A for bootstrapping, allo
|
||||
--Alongflagname disable bounds checking
|
||||
-C, --CCC a boolean defaulting to true (default true)
|
||||
--D path set relative path for local imports
|
||||
-E, --EEE num[=1234] a num with NoOptDefVal (default 4321)
|
||||
--F number a non-zero number (default 2.7)
|
||||
--G float a float that defaults to zero
|
||||
--IP ip IP address with no default
|
||||
@@ -987,6 +1024,8 @@ func TestPrintDefaults(t *testing.T) {
|
||||
fs.Lookup("ND1").NoOptDefVal = "bar"
|
||||
fs.Int("ND2", 1234, "a `num` with NoOptDefVal")
|
||||
fs.Lookup("ND2").NoOptDefVal = "4321"
|
||||
fs.IntP("EEE", "E", 4321, "a `num` with NoOptDefVal")
|
||||
fs.ShorthandLookup("E").NoOptDefVal = "1234"
|
||||
fs.StringSlice("StringSlice", []string{}, "string slice with zero default")
|
||||
fs.StringArray("StringArray", []string{}, "string array with zero default")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user