-
Notifications
You must be signed in to change notification settings - Fork 0
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
Introduce generate option to customize output #23
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Default the value to `:both` for backwards compatibility. Constraint the value to one of `:service`, `:client`, or `:both` and add spec to cover validation.
Note the differentiation here in client generation based on whether or not a service was also generated. When we have a service class, the client class can simply use the `client_for` DSL. Otherwise, we have to build the client from the service descriptor proto.
The complex example exercises more scenarios and will serve us better moving forward. Given that it also demonstrates correct namespace handling of imported types, the "import_type_retention" example was redundant.
There's some repeated code between "when specifying the `skip-empty` option" and when specifying the `skip-empty` and `generate=both` options" that we could do a better job of not repeating ourselves...
darronschall
force-pushed
the
introduce-generate-option
branch
from
May 17, 2024 11:56
889c26e
to
393768e
Compare
// 2. Using imported types for request and response types | ||
// 3. Services proto in a completely different package | ||
// | ||
// This file does _not_ demonstrate best practices. |
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.
🤣
danielmorrison
approved these changes
May 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #17
Add support for a new option on the
protoc
command line:--twirp_ruby_opt=generate=<service|client|both>
. This option customizes whether the plugin generates twirp services, clients, or both. Defaults toboth
when omitted to preserve backwards compatibility.generate=service
- only generate::Twirp::Service
subclass(es).generate=client
- only generate::Twirp::Client
subclass(es).generate=both
- generate both services and clients. This is the default option to preservebackwards compatibility.