cli icon indicating copy to clipboard operation
cli copied to clipboard

Using comma in flag name for alternatives breaks

Open erikwilson opened this issue 5 years ago • 2 comments

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

erikwilson avatar May 21 '20 13:05 erikwilson

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.

stale[bot] avatar Aug 21 '20 19:08 stale[bot]

Closing this as it has become stale.

stale[bot] avatar Sep 20 '20 19:09 stale[bot]