| This kind of "hey I will parse your CLI out of some callables' argspecs" has been done many times before: - https://github.com/fritzo/parsable.py - https://github.com/gissehel/cltools - https://github.com/piranha/opster - https://github.com/kennethreitz-archive/argue - https://github.com/pdubroy/simpleopt (all of those found from a 30 second GitHub search, so apologies if I've left one out or if one of those isn't exactly alike). The thing is, the fact that you cut out some code does not make your thing more Pythonic, or simpler, or easier to use by itself. It's definitely a start, but CLIs are hard. And while argparse has its issues, if you try to supplant it, I don't doubt that you can get the simple cases right, but it's the more complex composition of components that is hard to do, and that's why I find anything in this realm hard to latch onto. docopt is a nice step in a different direction, and I use it occasionally, but it's hard to do this -- for the simple cases argparse really isn't that bad, and I really really don't think that magically introspecting callables is a good approach. You will at some point want something more complicated, or to prevent some magic from doing somethings, and that kind of interface will become awkward, inextensible, and painful. Or at least that has been the case so far for anyone that's tried this. So, applaud any code that anyone's sharing, apologies for coming down hard, but I don't think this is something anyone should use for anything but a trivial "hey here's my CLI it's a one off, and I don't want to learn argparse [which takes an hour or two]". And even for that, docopt is probably a better option. |