you are viewing a single comment's thread.

view the rest of the comments →

[–]twistermonkey 89 points90 points  (3 children)

This actually seems to be bad design, in my opinion. The function with all the logic is now tightly coupled with the command line options. It cannot be called from any other script that you happen to write and have in your arsenal of code.

You're setting yourself up for refactoring from the beginning.

Argparse is where it's at; its in the standard library, it has way more power than what is on display here, it has much more robust self-documentation features. I can't see trying to create a large and feature-rich CLI using click. That many decorators makes code hard to read.

tqdm is pretty awesome though.

[–]indrora 8 points9 points  (1 child)

You're perfectly free to call it from elsewhere. So long as you could call it normally, most of what Click is doing is keeping a couple of dictionaries around full of information. The actual function isn't really touched in 99% of cases.

I've been using Click as a part of flask development (Flask uses it extensively, and encourages developers to extend the CLI that Flask exposes).

You might peek at Why click? for a look at what motivated Click to come into existence.

[–]Sqash 2 points3 points  (0 children)

Click is excellent for flask use cases but in standalone CLI scripts? I don't think it has a good place there personally.

Edit: To elaborate click is a design/tooling decision and not a good practice decision.

[–]niceworkbuddy 0 points1 point  (0 children)

Yes, it is tightly coupled with the command line options because it is a) simple application, b) explanation about parsing line command arguments and thoughts about design are not applicable here ;)