Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using comma in flag name for alternatives breaks #1142

Closed
3 tasks done
erikwilson opened this issue May 21, 2020 · 2 comments
Closed
3 tasks done

Using comma in flag name for alternatives breaks #1142

erikwilson opened this issue May 21, 2020 · 2 comments
Labels
area/v1 relates to / is being considered for v1 help wanted please help if you can! kind/bug describes or fixes a bug

Comments

@erikwilson
Copy link

erikwilson commented May 21, 2020

my urfave/cli version is

v1.22.4

Checklist

  • Are you running the latest v1 release? The list of releases is here.
  • Did you check the manual for your release? The v1 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.

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 erikwilson added area/v1 relates to / is being considered for v1 kind/bug describes or fixes a bug status/triage maintainers still need to look into this labels May 21, 2020
@stale
Copy link

stale bot commented Aug 21, 2020

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 stale bot added the status/stale stale due to the age of it's last update label Aug 21, 2020
@stale
Copy link

stale bot commented Sep 20, 2020

Closing this as it has become stale.

@stale stale bot closed this as completed Sep 20, 2020
@meatballhat meatballhat reopened this Apr 22, 2022
@meatballhat meatballhat removed the status/stale stale due to the age of it's last update label Apr 22, 2022
@meatballhat meatballhat changed the title altsrc v1 bug: using comma in flag name for alternatives breaks Using comma in flag name for alternatives breaks Apr 23, 2022
@meatballhat meatballhat added this to the Release 1.22.8 milestone Apr 23, 2022
@meatballhat meatballhat added help wanted please help if you can! and removed status/triage maintainers still need to look into this labels May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v1 relates to / is being considered for v1 help wanted please help if you can! kind/bug describes or fixes a bug
Projects
None yet
Development

No branches or pull requests

3 participants