summaryrefslogtreecommitdiff
path: root/vendor/github.com/urfave/cli/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/urfave/cli/context.go')
-rw-r--r--vendor/github.com/urfave/cli/context.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/vendor/github.com/urfave/cli/context.go b/vendor/github.com/urfave/cli/context.go
index db94191e2..552ee7405 100644
--- a/vendor/github.com/urfave/cli/context.go
+++ b/vendor/github.com/urfave/cli/context.go
@@ -3,6 +3,7 @@ package cli
import (
"errors"
"flag"
+ "os"
"reflect"
"strings"
"syscall"
@@ -73,7 +74,7 @@ func (c *Context) IsSet(name string) bool {
// change in version 2 to add `IsSet` to the Flag interface to push the
// responsibility closer to where the information required to determine
// whether a flag is set by non-standard means such as environment
- // variables is avaliable.
+ // variables is available.
//
// See https://github.com/urfave/cli/issues/294 for additional discussion
flags := c.Command.Flags
@@ -93,18 +94,26 @@ func (c *Context) IsSet(name string) bool {
val = val.Elem()
}
- envVarValue := val.FieldByName("EnvVar")
- if !envVarValue.IsValid() {
- return
+ filePathValue := val.FieldByName("FilePath")
+ if filePathValue.IsValid() {
+ eachName(filePathValue.String(), func(filePath string) {
+ if _, err := os.Stat(filePath); err == nil {
+ c.setFlags[name] = true
+ return
+ }
+ })
}
- eachName(envVarValue.String(), func(envVar string) {
- envVar = strings.TrimSpace(envVar)
- if _, ok := syscall.Getenv(envVar); ok {
- c.setFlags[name] = true
- return
- }
- })
+ envVarValue := val.FieldByName("EnvVar")
+ if envVarValue.IsValid() {
+ eachName(envVarValue.String(), func(envVar string) {
+ envVar = strings.TrimSpace(envVar)
+ if _, ok := syscall.Getenv(envVar); ok {
+ c.setFlags[name] = true
+ return
+ }
+ })
+ }
})
}
}