4 ms·
Defopt generates cli from function interface: https://defopt.readthedocs.io/en/stable/features.html https://defopt.readthedocs.io/en/stable/features.html The a
by KolenCh 2y ago
Defopt generates cli from function interface: https://defopt.readthedocs.io/en/stable/features.html https://defopt.readthedocs.io/en/stable/features.html
The alternative is either you maintain two interfaces with boilerplate, or write a cli only if that’s the first priority.
Similar solutions exist, like fire. But fire’s cli is like an afterthought, in the sense it gives people a way to run things in command line where they already know how to run it from Python.
- CableNinja 2y agoI wrote some stuff a while back to try and bridge this kind of issue. I wrote a spec: https://gitlab.com/accidentallythecable-public/argstruct-spec https://gitlab.com/accidentallythecable-public/argstruct-spe... And additionally, a library to build cli args and flags as well as api data from the same structure: https://gitlab.com/accidentallythecable-public/python-modules/python-argstruct https://gitlab.com/accidentallythecable-public/python-module... This allows you to build an argstruct file specifying commands, ars, descriptions, etc. You can then run an arbitrary callback against the commands, or use argparser for commandline