Merge branch 'master' into github-actions-windows

This commit is contained in:
Ajitem Sahasrabuddhe
2020-01-13 11:29:49 +05:30
36 changed files with 219 additions and 229 deletions

View File

@@ -4,6 +4,7 @@ package altsrc
import (
"flag"
"github.com/urfave/cli/v2"
)

View File

@@ -3,12 +3,13 @@ package altsrc
import (
"flag"
"fmt"
"github.com/urfave/cli/v2"
"os"
"runtime"
"strings"
"testing"
"time"
"github.com/urfave/cli/v2"
)
type testApplyInputSource struct {

View File

@@ -1,8 +1,9 @@
package altsrc
import (
"github.com/urfave/cli/v2"
"time"
"github.com/urfave/cli/v2"
)
// InputSourceContext is an interface used to allow

View File

@@ -2,10 +2,11 @@ package altsrc
import (
"flag"
"github.com/urfave/cli/v2"
"io/ioutil"
"os"
"testing"
"github.com/urfave/cli/v2"
)
const (

View File

@@ -3,11 +3,12 @@ package altsrc
import (
"encoding/json"
"fmt"
"github.com/urfave/cli/v2"
"io"
"io/ioutil"
"strings"
"time"
"github.com/urfave/cli/v2"
)
// NewJSONSourceFromFlagFunc returns a func that takes a cli.Context
@@ -78,9 +79,9 @@ func (x *jsonSource) Duration(name string) (time.Duration, error) {
if err != nil {
return 0, err
}
v, ok := (time.Duration)(0), false
if v, ok = i.(time.Duration); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(time.Duration)
if !ok {
return 0, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
@@ -90,9 +91,9 @@ func (x *jsonSource) Float64(name string) (float64, error) {
if err != nil {
return 0, err
}
v, ok := (float64)(0), false
if v, ok = i.(float64); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(float64)
if !ok {
return 0, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
@@ -102,9 +103,9 @@ func (x *jsonSource) String(name string) (string, error) {
if err != nil {
return "", err
}
v, ok := "", false
if v, ok = i.(string); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(string)
if !ok {
return "", fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
@@ -160,9 +161,9 @@ func (x *jsonSource) Generic(name string) (cli.Generic, error) {
if err != nil {
return nil, err
}
v, ok := (cli.Generic)(nil), false
if v, ok = i.(cli.Generic); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(cli.Generic)
if !ok {
return nil, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
@@ -172,9 +173,9 @@ func (x *jsonSource) Bool(name string) (bool, error) {
if err != nil {
return false, err
}
v, ok := false, false
if v, ok = i.(bool); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(bool)
if !ok {
return false, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}

View File

@@ -2,10 +2,11 @@ package altsrc
import (
"fmt"
"github.com/urfave/cli/v2"
"reflect"
"strings"
"time"
"github.com/urfave/cli/v2"
)
// MapInputSource implements InputSourceContext to return

View File

@@ -20,6 +20,6 @@ func TestMapDuration(t *testing.T) {
d, err = inputSource.Duration("duration_of_string_type")
expect(t, time.Minute, d)
expect(t, nil, err)
d, err = inputSource.Duration("duration_of_int_type")
_, err = inputSource.Duration("duration_of_int_type")
refute(t, nil, err)
}

View File

@@ -2,10 +2,11 @@ package altsrc
import (
"flag"
"github.com/urfave/cli/v2"
"io/ioutil"
"os"
"testing"
"github.com/urfave/cli/v2"
)
func TestCommandTomFileTest(t *testing.T) {

View File

@@ -2,10 +2,11 @@ package altsrc
import (
"flag"
"github.com/urfave/cli/v2"
"io/ioutil"
"os"
"testing"
"github.com/urfave/cli/v2"
)
func TestCommandYamlFileTest(t *testing.T) {