-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
area/v2relates to / is being considered for v2relates to / is being considered for v2kind/bugdescribes or fixes a bugdescribes or fixes a bugstatus/triagemaintainers still need to look into thismaintainers still need to look into this
Milestone
Description
my urfave/cli version is
v2.3.0
Checklist
- Are you running the latest v2 release? The list of releases is here.
- Did you check the manual for your release? The v2 manual is here
- Did you perform a search about this problem? Here's the Github guide about searching.
Dependency Management
- My project is using go modules.
- My project is using vendoring.
- My project is automatically downloading the latest version.
- I am unsure of what my dependency management setup is.
Describe the bug
Flag names missing in cli.Context.FlagNames()
if set via env. variables.
To reproduce
package main
import (
"fmt"
"github.com/urfave/cli/v2"
"log"
"os"
)
func main() {
app := &cli.App{
Flags: []cli.Flag{
&cli.StringFlag{
Name: "testvar",
EnvVars: []string{"TESTVAR"},
},
}, Action: func(c *cli.Context) error {
fmt.Println("FlagNames()\t", c.FlagNames())
fmt.Println("testvar\t\t", c.String("testvar"))
return nil
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
Observed behavior
$ ./main --testvar testval
FlagNames() [testvar]
testvar testval
$ TESTVAR=testval ./main
FlagNames() []
testvar testval
Expected behavior
I expect cli.Context.FlagNames()
to return flag names irrespectively of which way they were set.
Run go version
and paste its output here
$ go version
go version go1.16.2 linux/amd64
cvigo
Metadata
Metadata
Assignees
Labels
area/v2relates to / is being considered for v2relates to / is being considered for v2kind/bugdescribes or fixes a bugdescribes or fixes a bugstatus/triagemaintainers still need to look into thismaintainers still need to look into this