6 ms·
The proposed solution of an API with a thinly wrapped auto-generated CLI is not terrible. I have heard it is common within Google, for example. In the Python
by cb321 4y ago
The proposed solution of an API with a thinly wrapped auto-generated CLI is not terrible. I have heard it is common within Google, for example.
In the Python world, there are various solutions starting from https://github.com/ialbert/plac https://github.com/ialbert/plac or https://argh.readthedocs.io/en/latest/ https://argh.readthedocs.io/en/latest/ and moving on to https://github.com/pallets/click https://github.com/pallets/click or https://github.com/Lucretiel/autocommand https://github.com/Lucretiel/autocommand and probably N others.
Personally, I prefer Nim to Python which has https://github.com/c-blake/cligen https://github.com/c-blake/cligen. As mentioned in https://github.com/c-blake/cligen/blob/master/MOTIVATION.md https://github.com/c-blake/cligen/blob/master/MOTIVATION.md, but not in the borretti article, the overhead of dispatch to a program in shell REPLs can also be thousands to millions of times higher than an API call.
- GauntletWizard 4y agoI have had great success creating DSLs using ipython, where you simply define a set of classes and functions on them, then use ipython.embed() (Before it was terminal.embed, so you can see where the experience is dated).
- tzhenghao 4y agoI've used click [1] a lot to build Python tooling scripts the past few years. Click usage is "sort of" similar to the author's proposed solution. There's also a small section here [2] that describes some of the issues covered in the article (in context of argparse). [1] - https://github.com/pallets/click https://github.com/pallets/click [2] - https://click.palletsprojects.com/en/8.1.x/why/#why-not-argparse https://click.palletsprojects.com/en/8.1.x/why/#why-not-argp...