Comments (2)
The decorators themselves don't do much besides creating Argument
or Option
instances. So while you could potentially split up the interface into flags, options, arguments, counters and whatnot it would not make sense to split the lower level class up because there really is not that much stuff in there that can be clearly isolated.
As an example do options become flags by various modes. For instance option('--foo/--bar')
automatically makes something into a flag, same with option('--foo', flag_value='whatever')
.
Counters can't become a separate decorator easily either because a counter still accepts all the other behaviors of an option (sans counter). For instance you can set a default or change the type from an integer to a integer range etc.
The only thing you would gain at the end of the day is to make the edge case @click.option('--x', is_flag=True)
(which is strongly discouraged!) to @click.flag('-x')
. I'm not sure I like that.
But more than anything, once you go down that road you now have the problem that certain behavior is restricted to options whereas it would otherwise also work for arguments. In case of flags here is no reason why at one point we might not find a use for exposing them to arguments as well.
It's not really possible to "create decorators" that hold this functionality because the decorators don't actually do anything. The underlying class does, and that class does multiple things at once and is not clearly cut and separated.
from click.
Thank you for your clarification. I will spend some time with the source code before answering.
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
- Utility to introspect known command arguments HOT 3
- 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.