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

StringSliceFlag will show it's value as default if failed in Before: #1076

Closed
3 tasks
arykalin opened this issue Feb 25, 2020 · 4 comments
Closed
3 tasks

StringSliceFlag will show it's value as default if failed in Before: #1076

arykalin opened this issue Feb 25, 2020 · 4 comments
Labels
area/v2 relates to / is being considered for v2 help wanted please help if you can! kind/bug describes or fixes a bug status/confirmed confirmed to be valid, but work has yet to start
Milestone

Comments

@arykalin
Copy link

my urfave/cli version is

( Put the version of urfave/cli that you are using here )

Checklist

  • [v] Are you running the latest v2 release? The list of releases is here.
  • [v] Did you check the manual for your release? The v2 manual is here
  • [v] Did you perform a search about this problem? Here's the Github guide about searching.

Dependency Management

  • [v] 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

StringSliceFlag will show it's actual value as default if failed in Before.

To reproduce

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/urfave/cli/v2"
)

func main() {
	app := &cli.App{
		EnableBashCompletion: true,
		Commands: []*cli.Command{
			{
				Name: "wat",
				Flags: []cli.Flag{
					&cli.StringSliceFlag{Name: "dance-move"},
				},
				Before: func(context *cli.Context) error {
					return fmt.Errorf("I fail")
				},
			},
		},
	}
	err := app.Run(os.Args)
	if err != nil {
		log.Fatal(err)
	}
}

Observed behavior

./main wat --dance-move 1111

2020/02/25 20:11:17 I fail
NAME:
   urfave_cli wat - 

USAGE:
   urfave_cli wat [command options] [arguments...]

OPTIONS:
   --dance-move value  (default: "1111")
   --help, -h          show help (default: false)
   

Process finished with exit code 1

Expected behavior

./main wat --dance-move 1111

2020/02/25 20:11:17 I fail
NAME:
   urfave_cli wat - 

USAGE:
   urfave_cli wat [command options] [arguments...]

OPTIONS:
   --dance-move value
   --help, -h          show help (default: false)
   

Process finished with exit code 1

Additional context

Add any other context about the problem here.

If the issue relates to a specific open source Github repo, please link that repo here.

If you can reproduce this issue with a public CI system, please link a failing build here.

Want to fix this yourself?

We'd love to have more contributors on this project! If the fix for this bug is easily explained and very small, free free to create a pull request for it.

Run go version and paste its output here

go version go1.13.4 linux/amd64

Run go env and paste its output here

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build885487390=/tmp/go-build -gno-record-gcc-switches"
@arykalin arykalin added area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this labels Feb 25, 2020
@coilysiren
Copy link
Member

@arykalin can you remove the sections of the issue template that you didn't fill out? thanks ✨

This feels like the same issue as #981, or possibly it's just conceptually similar.

At any rate, I'm fairly certain that I understand the bug here 👍 marking this as help wanted

@coilysiren coilysiren added help wanted please help if you can! status/confirmed confirmed to be valid, but work has yet to start and removed status/triage maintainers still need to look into this labels Feb 26, 2020
@stale
Copy link

stale bot commented May 26, 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 May 26, 2020
@stale
Copy link

stale bot commented Jun 25, 2020

Closing this as it has become stale.

@stale stale bot closed this as completed Jun 25, 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 v2 bug: StringSliceFlag will show it's value as default if failed in Before: StringSliceFlag will show it's value as default if failed in Before: Apr 22, 2022
@dearchap
Copy link
Contributor

Problem is in a release that is very very old. Cant reproduce on latest release. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 help wanted please help if you can! kind/bug describes or fixes a bug status/confirmed confirmed to be valid, but work has yet to start
Projects
None yet
Development

No branches or pull requests

4 participants