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

Make it easy to generate help section and version show up #15

Open
remyleone opened this issue Apr 25, 2024 · 1 comment
Open

Make it easy to generate help section and version show up #15

remyleone opened this issue Apr 25, 2024 · 1 comment

Comments

@remyleone
Copy link

When I'm doing protoc-gen-X --help I would expect to have a little section about how I can configure buf to use this plugin, what are the different options available that I can pass in my buf.gen.yaml.

When I'm doing a protoc-gen-X --version I would expect the version to show up.

Could it be possible for protoplugin to implement interface that support all of that? Having validation that ensure that all options are documented could be really helpful as well :)

@mfridman
Copy link
Member

mfridman commented Apr 25, 2024

The --version flag is supported but is an opt-in option for Run and Main, see:

protoplugin/protoplugin.go

Lines 105 to 115 in e2735f6

// WithVersion returns a new RunOption that will result in the given version string being printed
// to stdout if the plugin is given the --version flag.
//
// This can be passed to Main or Run.
//
// The default is no version flag is installed.
func WithVersion(version string) RunOption {
return optsFunc(func(opts *opts) {
opts.version = version
})
}

Regarding the first point on --help I think that's an interesting one because something I've always wanted in the Protobuf ecosystem is to have a common way to configure, view and retrieve available options (in a programmatic way). This is typically left to plugin maintainers to keep up-to-date in README or doc pages, and surely there's gotta be a better way.

protogen allows you to use a *flag.FlagSet, so you can have the same set of options be displayed in --help and used as Protobuf plugin options, e.g., --go_out=<param1>=<value1>

flag.Parse()
protogen.Options{
	ParamFunc: flag.CommandLine.Set,
}.Run

I think there's an opportunity here to improve the story around Protobuf plugin options for the whole community.

I'm sure @bufdev has some thoughts and opinions on plugin options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants