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
Add TakesFile
to fish shell completion
#857
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,10 @@ type DocGenerationFlag interface { | |
// GetValue returns the flags value as string representation and an empty | ||
// string if the flag takes no value at all. | ||
GetValue() string | ||
|
||
// GetTakesFile indicates that the command takes a file as input, which | ||
// will be used for documentation and completion generation purposes. | ||
GetTakesFile() bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given we have TakesValue() this should be TakesFile()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Golang will complain if we have a method and a value with the same name and it seems that we follow a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then why do we a method at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I removed it completely. |
||
} | ||
|
||
// errorableFlag is an interface that allows us to return errors during apply | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just don't generate these for things that do not take files, and do an interface assertion in the generation code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, the issue is that we have this method as part of the
DocGenerationFlag
, which we already type assert in fish.go. If we remove the function from the other flags we would not be able any more to generate docs/completions for them, because the type assertion fails:cli/fish.go
Lines 122 to 125 in a1cf7f4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? You can assert something more than once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I added a helper function to check if we can access the
TakesFile
variable.