Comments (1)
@thedrow Looks like the answer is no. Using the included example PrintIt
package as the example package that receives plugins I tried modifying PrintItBold
to override the upper
command:
$ pip install -e example/PrintIt
$ printit --help
Usage: printit [OPTIONS] COMMAND [ARGS]...
Format and print file contents.
For example:
$ cat README.rst | printit lower
Options:
--help Show this message and exit.
Commands:
lower Convert to lower case.
upper Convert to upper case.
First I defined a new upper()
function in example/PrintItBold/printit_bold/core.py
@click.command()
def upper():
"""
Override.
"""
click.echo("Override.")
Then I registered it as a plugin in example/PrintItBold/setup.py
upper=printit_bold.core:upper
Installing the plugin shows a new bold
command as expected, however the upper
command is from PrintIt
and not PrintItBold
.
$ pip install -e example/PrintItBold
$ printit --help
Usage: printit [OPTIONS] COMMAND [ARGS]...
Format and print file contents.
For example:
$ cat README.rst | printit lower
Options:
--help Show this message and exit.
Commands:
bold † Warning: could not load plugin. See `printit bold --help`.
lower Convert to lower case.
upper Convert to upper case.
Removing the code defining the upper
command does cause the new upper
command to be exposed:
$ printit --help
Usage: printit [OPTIONS] COMMAND [ARGS]...
Format and print file contents.
For example:
$ cat README.rst | printit lower
Options:
--help Show this message and exit.
Commands:
bold † Warning: could not load plugin. See `printit bold --help`.
lower Convert to lower case.
upper Override.
So this feature is feasible given that technically the parent command is overriding the plugin, but after stepping through this the current behavior seems correct. Preserving the parent commands offers consistency to all users and instead forces alternate command implementations to register themselves under new names. If a plugin overrides the parent command with the same help text but behaves differently then it could be difficult to identify exactly why the command is behaving differently. I can see this scenario happening:
- A user depends on a specific package with a specific command.
- They install some other package.
- That package has a dependency that the user did not explicitly install.
- The dependency overrides the CLI command that the user depends on.
- The CLI command may or may not clearly be different and may or may not provide drastically different behavior.
from click-plugins.
Related Issues (20)
- Port from PR
- Release 1.0.2 HOT 1
- Allow with_plugins() to accept a string
- Cleanup docs
- Using plugin alias that doesn't match click.group method name HOT 2
- test_group_chain fails with python-click 6.7+git20180829-1 HOT 4
- Release v1.0
- Release 1.0.4 HOT 1
- Investigate performance HOT 1
- List plugin commands in separate sections? HOT 1
- A broken command with arguments hides failure trace
- Enable Travis-CI and coveralls.io HOT 5
- [ERROR] Package has no install method: python-click-plugins HOT 1
- Entry points can not be loaded if there is a package version conflict anywhere in the environment HOT 7
- click 8+ comapt new release HOT 2
- @with_plugins() causes a type error in PyCharm
- "show_envvar=True" inside plugins shows . used in environment variable name HOT 1
- Clarify `pkg_resources` vs `importlib_metadata`
- Release 1.0.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from click-plugins.