-
-
Notifications
You must be signed in to change notification settings - Fork 513
Add help text to binary #2885
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
base: master
Are you sure you want to change the base?
Add help text to binary #2885
Conversation
qdm12
left a comment
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.
Thanks, a few adjustments to be made + eventual refactor of other code parts
internal/cli/help.go
Outdated
| "fmt" | ||
| ) | ||
|
|
||
| func (c *CLI) Help() { |
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.
Actually, in order to later not forget to add a help message... it would be cool if each command be a struct implementing the interface
type Command interface {
Run() error
Name() string // for example "help", "genkey"
Description() string // for example "Update the VPN servers data for some or all providers"
}And then the help command would take a slice of all commands to print the help message? That would require to refactor a bit existing commands, so it's fine if you want to skip this comment as well.
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.
sounds good.
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.
I've made an attempt at a refactor with 2af3d40, let me know what you think.
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.
I'll review shortly, just rushing for a v3.41.0 release currently.
The commands are not discoverable:
I was only aware of them because I happened to snoop around the codebase.
Ironically, as we use flags, some of the commands do have help text:
This PR adds new help text when a use provides
-helpor--help, the help text is printed by default: