Comments (3)
pre-commit only allows adding args to the end
Yeah, but that doesn't prevent you from passing what you want:
command: my_command
additional_args: --opt a my_sub --other b
Besides that, it's already possible to introspect the available options and commands, so I'm not really clear what else would be needed or what it would do.
from click.
Let's dig into this a bit more. Consider the .pre-commit-hooks.yaml
- entry: my_command
args: --opt a my_sub --other b
Now the user would want to add --root /path/to/root
to my_command
so they write in the .pre-commit-config.yaml
- id: "..."
args: [ --root, /path/to/root ]
This is than expanded and used as
$ my_command --opt a my_sub --other b --root /path/to/root
Note how --root
is passed to my_sub
instead of my_command
. I don't remember the documentation page on how to make arguments pass from command to subcommand, but I remember trying that out and having had troubles with clashing kwargs
that made adding --root
as an option to my_sub
and having it transparently passed down to my_command
not possible. (Don't remember if it was even possible)
Now handling one argument is doable, but this CLI is growing rather quick and keeping synced all of the possible arguments that it supports can quickly be problematic. That's why it would be useful to write an automatic way of filtering the arguments so that we can re-order the arguments such that internally we have these equivalent:
$ precommit_my_command --opt a my_sub --other b --root /path/to/root
$ my_command --root /path/to/root --opt a my_sub --other b
from click.
Besides that, it's already possible to introspect the available options and commands, so I'm not really clear what else would be needed or what it would do.
I couldn't find the relevant API or documentation page.
Oh, if you are referring to inspect.signature
, that simply gave me *args, **kwargs
.
from click.
Related Issues (20)
- DOC: Add chapter on how to debug a CLI with pdb HOT 2
- Allow Hiding of Range Values for IntRange Option in --help HOT 2
- Revisiting stderr flush in CLIRunner
- feature: allow substituting command_path in command help and epilog text
- Wront Usage when running a module with python -m HOT 1
- format_help_text does not format text in a group HOT 5
- Conditionally apply options to input
- Click performance is poor HOT 1
- Request to document some basic features explicitly HOT 2
- show envvar in error hint HOT 3
- Broken message about invalid argument value for template "File ... is a directory" HOT 1
- Missing return value in context manager example (Managing resources)?
- zsh completion still misbehaving in the presence of `:`
- Setting color=True in runner.invoke on windows strips ansi codes HOT 2
- Better i18n with gettext: use class-based API
- Broken code example in docs under Advanced Patterns
- Autocorrect wrong/misspelled option with the suggested unique possibility. HOT 1
- Docs wrongly links PRs and Issues to flask
- The type hint for the filename parameter to open_file is incomplete 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.