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

Fix missing plug-ins from vpype --help string #444

Merged
merged 2 commits into from
Apr 2, 2022

Conversation

abey79
Copy link
Owner

@abey79 abey79 commented Apr 1, 2022

Description

When importing plug-ins in the style of click-plugin (command decorator, so plug-ins are loaded during the loading of the top-level command itself), plug-ins may not import from vpype_cli (since it isn't fully loaded). To address that, since 1.9, loading plug-ins is deferred to when cli is actually executed. As a result, the Click's default behaviour for handling --help (i.e. print and exit before even executing cli) is unable to list the plug-ins. This PR addresses this by manually handling the top-level --help parameter (after plug-ins are loaded).

Fixes #432

Checklist

  • feature/fix implemented
  • code formatting ok (black and isort)
  • mypy returns no error
  • tests added/updated and pytest succeeds
  • documentation added/updated
    • command docstring and option/argument help
    • README.md updated (Feature Overview)
    • CHANGELOG.md updated
    • added new command to reference.rst
    • RTD doc updated and building with no error (make clean && make html in docs/)

When importing plug-ins in the style of `click-plugin` (command decorator, so plug-ins are loaded during the loading of the top-level command itself), plug-ins may not import from `vpype_cli` (since it isn't fully loaded). To address that, since 1.9, loading plug-ins is deferred to when `cli` is actually executed. As a result, the Click's default behaviour for handling `--help` (i.e. print and exit *before* even executing `cli`) is unable to list the plug-ins. This commit addresses this by manually handling the top-level `--help` parameter (*after* plug-ins are loaded).

Fixes #432
@codecov
Copy link

codecov bot commented Apr 1, 2022

Codecov Report

Merging #444 (ab360e0) into master (11ebcf1) will increase coverage by 0.33%.
The diff coverage is 75.00%.

@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
+ Coverage   93.98%   94.31%   +0.33%     
==========================================
  Files          60       60              
  Lines        5301     5313      +12     
  Branches      776      778       +2     
==========================================
+ Hits         4982     5011      +29     
+ Misses        204      185      -19     
- Partials      115      117       +2     
Impacted Files Coverage Δ
vpype_cli/cli.py 86.44% <66.66%> (+10.55%) ⬆️
tests/test_commands.py 99.04% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11ebcf1...ab360e0. Read the comment docs.

- Fixed multiple plug-in loading when using `vpype_cli.execute()` multiple times
- updated CHANGELOG.md
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@abey79 abey79 merged commit 7076c03 into master Apr 2, 2022
@abey79 abey79 deleted the fix-help-plugins-missing branch April 2, 2022 10:30
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

Successfully merging this pull request may close these issues.

Plug-ins are no longer displayed with vpype --help
1 participant