Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Switch CLI arg processing to docopt #228

mmabey opened this Issue · 7 comments

4 participants


I know it would be a significant refactor, but the docopt library is so much cleaner and easier to read than argparse and I think it would be worthwhile to make the switch. The length of would be half its current length easily, and without all the confusing parameters to create each argument and option.

I know that references methods from the args object, so to continue to accommodate this, I've already started writing a wrapper for the bunch library that would allow a smoother transition to using docopt.

In terms of compatibility, docopt is compatible with Python 2.5+ and 3.x, and bunch is a fairly simple wrapper around the dict object, so there shouldn't be an issue with the versions of Python that HTTPie woks with.

In any case, I wanted to get some feedback about this idea before I started real work on it. So what do you think?


If changing command line parsing library is an option why not consider click


Except that argparse is just as popular (if not more popular) than docopt so I would expect new contributors to more easily understand argparse based on their experience with it. If you instead mean "new Pythonistas who want to contribute", then I don't see how the magic that is taking the docstring and turning it into command-line flags is easy to understand to a new Pythonista.


I guess I was basing my estimation of effort on the simplicity of docopt, not on its popularity. After all, isn't simple better than complex? And at least in my book, readability counts, which I think docopt also has in its favor over argparse, even if for the simple fact that the documentation is so much shorter.

I understand that I'm not going to win over argparse aficionados to use docopt. But IMHO, regardless of your programming experience, having the help text in one place instead of spread over 20+ method calls is easier to work with, as is having a dict with all your arguments and flags named the same thing as in the help text.


@mmabey I appreciate the initiative :+1:

HTTPie's focus is user experience, code readability comes in second. argparse is far from perfect (e.g. #125, #239), but it does its job reasonably well. Please keep in mind that the CLI is complex and somewhat unusual.

I'd argue that the way the CLI is defined is far from unmaintainable ( What is quite messy though is the additional logic layer in

So, unless docopt (or click) allows the same (or higher) degree of flexibility while significantly reducing code complexity, I'd strongly prefer sticking with argparse (whose additional advantage is that it's included in the stdlib of newer Python versions).

Update: See also

@jkbrzt jkbrzt added feature CLI decide and removed decide labels

If I'm following the twitter conversation properly, docopt is out of the question (assuming of course that we want full backwards compatiblity).


@sigmavirus24 Yes. I guess we can revisit this again in the future. Closing for now.

@jkbrzt jkbrzt closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.