by shangxiao · 5y ago · 0 comments
It's called bargeparse [1]. The idea is to define an entry point function and use its signature as a means to declare the CLI arguments & options. I was surprised at how well Python's syntax for function arguments works for this... especially the use of pos-only & keyword-only arguments to force a particular style.
I've taken the liberty to post your project to my Python news aggregator over here[1].
[1] https://news.python.sc/item/0d111c5d-0eff-41d5-8d5c-ecb18301...
There are some others like yours:
Google's python-fire (1)
Docopt (2), which creates the cli from the documentation instead of the other way around
Click (3)
And my own commandeer (4)
Typer (5)
(1) https://github.com/google/python-fire (2) http://docopt.org/ (3) https://click.palletsprojects.com/en/8.0.x/ (4) https://pythonhosted.org/Commandeer/index.html (5) https://typer.tiangolo.com/
Having said that bargeparse was meant to rely solely on stdlib as the environment we were operating in was tightly controlled and any 3rd party packages had to go through a lengthy review process to be whitelisted.
Additionally, since our team (and others in our organisation) were mostly using argparse, the goal was to provide a way to declaratively interact with it using existing features in the language itself.
If you want something older and with a similar api (wrapping argparse), using only the stdlib, I can ask the same question with argh, which already worked in python 2.6.
So why write another one?
I have noticed that happening regularly and out of curiousity interviewed those fellow programmers. I found out it's not because of lack of diligence, or because they attribute no value to a survey, but because of a risk-loving psychology trait that expresses itself in staking out ground and claiming it as one's own. (Armchair psychology warning, I am not qualified to make that conclusion; leave the real work confirming this hypothesis to the scientists in the field.)
IMO, this behaviour is harmful and we should work together to socially shun it like we already do for compulsive hoarding of physical objects. We have trouble finding a piece of software that works well because we spend so much effort to repeatedly sift through the mountains of published software that is mostly garbage.