Implement command line interface#165
Draft
Gobot1234 wants to merge 54 commits intodanielgtaylor:masterfrom
Draft
Implement command line interface#165Gobot1234 wants to merge 54 commits intodanielgtaylor:masterfrom
Gobot1234 wants to merge 54 commits intodanielgtaylor:masterfrom
Conversation
This means the betterproto plugin no longer needs to depend durectly on protobuf. This requires a small runtime hack to monkey patch some google types to get around the fact that the compiler uses proto2, but betterproto expects proto3. Also: - regenerate google.protobuf package - fix a regex bug in the logic for determining whether to use a google wrapper type. - fix a bug causing comments to get mixed up when multiple proto files generate code into a single python module
- Remove plugin dependency on protobuf since it's no longer required. - Update poethepoet to for better pyproject toml syntax support - Add handy generate_lib poe task for maintaining generated libs
Collaborator
Author
|
grcp support still needs to be tested but I currently can't do that myself. |
# Conflicts: # tests/test_features.py
# Conflicts: # poetry.lock # pyproject.toml # src/betterproto/plugin/main.py # src/betterproto/plugin/models.py # src/betterproto/plugin/parser.py # tests/inputs/oneof/test_oneof.py # tests/util.py
Gobot1234
commented
Apr 2, 2021
Collaborator
Author
|
Small update on this and my parsing library, I can successfully parse file inputs using protoc, unfortunately making a run function doesn't appear to be very feasible ATM, but I'm hopeful I can get this figured out relatively quickly. |
# Conflicts: # README.md # pyproject.toml # src/betterproto/plugin/compiler.py # src/betterproto/plugin/main.py # src/betterproto/plugin/models.py # src/betterproto/plugin/parser.py # tests/generate.py # tests/test_features.py # tests/util.py
This file contains hidden or 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
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.
Implements a command line interface for the module abstracting away the use of protoc to under the hood.
Objectives
How to improve current implementation
Custom options
Backwards compatibility
This is obviously important. I plan to achieve this with an ENV var which will determine whether or not protoc was invoked with the plugin if it wasn't invoked with protoc I would like to display a warning saying that direct invocation of protoc is depreciated and the command they could use in the future.
Programmatic access
I plan to make a few functions accessible using the betterproto API under the name
compile_protobufsin the plugin package using https://github.com/Gobot1234/protobuf-parser.TODO:
% betterproto compile --help Usage: betterproto compile [OPTIONS] PATHS... The recommended way to compile your protobuf files. Arguments: PATHS... The protobuf files to compile [required] Options: -v, --verbose Whether or not to be verbose [default: False] -l, --line-length INTEGER The line length to format with [default: 88] --generate-services / --no-generate-services Whether or not to generate servicer stubs [default: True] --output DIRECTORY The name of the output directory -h, --help Show this message and exit.Main entry point for compilation is with
betterproto compilethis will make it potentially easier to add custom arguments for compilation down the road and makes invocation much simpler as with the old system you would have to run:Whereas now it is: