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
v2 bug: fishAddFileFlag doesn't work with PathFlag #1156
Comments
I think a case statement would be preferred over a reflection here, although I feel like you should be able to check type takesFile struct {
TakesFile bool
}
# ...
f, ok := flag.(takesFile); ok {
if f.TakesFile {
return
}
} let me know if that makes sense! Either way, I'm interested in whatever you come up with! |
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. |
Performing reflection on the given flag ensures that fishAddFileFlag will behave correctly if any flag types get a TakesFile field in the future.
Sorry for letting this get stale! I’ve opened a PR. |
This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant. |
This reverts commit fcce511.
my urfave/cli version is:
2.2.0
Checklist
Dependency Management
Describe the bug
By default,
fishAddFileFlag
adds-f
to thecomplete
command, indicating that the input to the flag shouldn't be a filename. Naturally, aPathFlag
should accept a filename, butfishAddFileFlag
only checksGenericFlag
,StringFlag
, andStringSliceFlag
.To reproduce
Create a
main.go
:Observed behavior
run
go run ./main.go
. The output will include:Expected behavior
The first line, for
path-file
, shouldn't have-f
.Want to fix this yourself?
Sure! I could add another case statement for
PathFlag
, but usingreflect
might be more future-proof. Do you have a preference?Run
go env
andgo version
Output of those commands
go version
go env
The text was updated successfully, but these errors were encountered: