Comments (4)
I like this idea. I didn't do it originally because I didn't want adding a parameter to be able to break backwards compatibility. For example, if you later come and add baz
, you'll lose the -b
. I think if we do this it should be opt-in. Also note that you already get the default argparse behavior of allowing unambiguous shortened flags, e.g. --f
and --fo
.
Would you like to work on a PR?
from defopt.
I don't think(?) shortened long flags can be stacked as --abc
(for --a --b --c
).
This feature doesn't necessarily break backcompatibility as you can apparently just pass whatever short flags you want to defopt.run
(although an example is actually missing at http://defopt.readthedocs.io/en/latest/examples.html#module-examples.short). So if someone wants to add a second option with the same initial, they has the choice of whether to break backcompat, or just disambiguate things themselves.
No time for a PR right now...
from defopt.
No, the shortened long flags won't stack.
My concern is not that the feature itself will break backwards compatibility, rather that having it enabled by default will create a gotcha where a developer can remove a flag without realizing. The tools will still be there to restore the short flag once they notice. I don't know whether this is a strong enough argument for having it off by default, though.
from defopt.
If you really want to play extra safe, you could issue a warning whenever multiple short flags conflict (with an option to disable it). But that would break backcompatibility of defopt.
I don't think the backcompatibility issue on the user side is that big, even if the dev does no testing -- at worst, what happens is that someone was using a short flag, sees that it doesn't work anymore, complains to the dev, who realizes the issue and resolves it manually. It's never going to run an incorrect command, at least.
from defopt.
Related Issues (20)
- Add a registry class HOT 4
- When subclassing enum with data mixin, choices are not present on CLI HOT 8
- Consume command line arguments in 2 function calls HOT 10
- Support URLs in docstring
- Reject duplicate options for a single parameter rather than silently dropping one HOT 2
- Any way to indent within tool help text without runtime / linting error? HOT 1
- Add support for datetime.date and datetime.datetime parsers HOT 5
- Argument name suffixes as workaround for name collisions HOT 4
- Should `Optional[Tuple[type1]]` be supported HOT 7
- PyInstaller, Nuitka compatibility? HOT 5
- pin setuptools_scm < 6.4 to support python3.6 HOT 2
- Consume command line arguments in 2 calls - help text has only one call's parameters HOT 17
- Using keyword only dataclass with `defopt.run` gives a docutils warning HOT 1
- py.typed file? HOT 3
- NotImplementedError: <class 'defopt._parse_docstring.<locals>.Visitor'> visiting unknown node type: definition_list HOT 3
- TypeError: can only join an iterable HOT 2
- Requestion: add an option to convert underscores to hyphens for all arguments HOT 2
- [BUG] Pyinstaller does not resolve defopt import HOT 5
- Support repeated options that take a single argument (action=append) HOT 2
- Support for blank lines and indentation in argument help HOT 2
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 defopt.