by kortex · 4y ago · 0 comments
My criteria are: well supported, composable, sub commands, reusable options, sane stack traces.
My current pattern: Cleo plus pydantic. I can create a module of commonly used flags and options that I can share among commands. Commands are first class objects. I can use them as entry points. I can readily parse the options into a static structure with defaults read from env or a file using pydantic. This is feed to runner/API functions, with minimal logic in the command class itself. The one thing that is lacking is I wish I could define pydantic models that double as commands. That is a pretty specific nit to pick.
Overall I love it. Poetry runs on it so I think it's got a long support life. It's beautiful. Easy to use. Just the right amount of opinionated for me. Supports auto complete. Built in commonly used flags like version, quiet, and verbose levels.
I find click and any of the decorator based systems super obtuse and difficult to compose. They add tons of noise to stack traces.
Docopt is way too string based. I like static types.
Argparse is... surprisingly not bad. The main drawback is reuse is not very easy and it's hard to write composable structures.
No comments yet.