cli
cli copied to clipboard
Using comma in flag name for alternatives breaks
my urfave/cli version is
v1.22.4
Checklist
- [X] Are you running the latest v1 release? The list of releases is here.
- [X] Did you check the manual for your release? The v1 manual is here
- [X] 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.
Describe the bug
When using alternates in flag names altsrc does not copy the flag value.
To reproduce
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli"
"github.com/urfave/cli/altsrc"
)
var (
test int
)
func main() {
app := cli.NewApp()
flags := []cli.Flag{
altsrc.NewIntFlag(cli.IntFlag{Name: "test,t", Destination: &test}),
cli.StringFlag{Name: "load"},
}
app.Action = func(c *cli.Context) error {
fmt.Printf("Have test value: %d\n", test)
return nil
}
app.Before = altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("load"))
app.Flags = flags
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
echo test: 1 >conf
GO111MODULE=on go run test.go --load conf
Observed behavior
Have test value: 0
Expected behavior
Have test value: 1
Additional context
Previously reported in #711
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.
Closing this as it has become stale.