-
Notifications
You must be signed in to change notification settings - Fork 70
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
refactor: Use inheritance to construct plugin CLI #936
Conversation
2af92c5
to
0c18a57
Compare
Codecov Report
@@ Coverage Diff @@
## main #936 +/- ##
==========================================
+ Coverage 85.13% 85.47% +0.34%
==========================================
Files 59 59
Lines 4890 4888 -2
Branches 810 802 -8
==========================================
+ Hits 4163 4178 +15
+ Misses 527 510 -17
Partials 200 200
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
df0e299
to
b5af06a
Compare
b5af06a
to
34be86e
Compare
daeab2d
to
8794cbd
Compare
f6ed78e
to
487bbe8
Compare
afca935
to
0e4bb7a
Compare
ac91c3d
to
58cc655
Compare
58cc655
to
6ab14f3
Compare
@edgarrmondragon have you seen this? I was wondering if a similar approach would allow us to add a new attribute |
Thanks for sharing @kgpayne! After reviewing it, I don't think a pattern like that is something we can adopt without significant changes to the plugin class. A lot of the CLI options we currently support can and should be handled by simple callbacks (as this PR implements) and following the pattern in the link prohibits setting callbacks from class methods for things like version, discovery, etc. It also forces us to implement a God-method that handles all options (the status quo), which gets ugly as exemplified by tap-airbyte's implementation requiring too many copy and pasting.
I've pushed another commit to the PR that changes the class ShortcutTap(Tap):
@plugin_cli
def update_schema(cls) -> click.Command:
"""Update the OpenAPI schema for this tap."""
@click.command()
def update():
response = requests.get(
"https://developer.shortcut.com/api/rest/v3/shortcut.swagger.json",
timeout=5,
)
with Path("tap_shortcut/openapi.json").open("w") as f:
f.write(response.text)
return update Also also, there's nothing stopping users from declaring custom CLIs and registering in Wdyt? |
@edgarrmondragon this looks great 🙌 Will do a full review tomorrow, but a docs addition would be helpful to support adoption/experimentation e.g. MeltanoLabs/target-snowflake#21 🙂 |
Thanks for calling out the lack of docs! I've added a short guide in https://meltano-sdk--936.org.readthedocs.build/en/936/guides/custom-clis.html |
@edgarrmondragon my only thought is that it'd be great to have a more full-featured example for the docs in time. I learned from the Click codebase that |
Sounds good 👍 |
No description provided.