Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Accept options after HTTP method #125

merwok opened this Issue Jan 23, 2013 · 3 comments


None yet
2 participants

merwok commented Jan 23, 2013

http --form POST etc works but not http POST --form, which is surprising.


jakubroztocil commented Jan 25, 2013

This is unfortunately a limitation of argparse. It doesn't seem to allow the placement of boolean flags between positional arguments. A minimal test case:

#!/usr/bin/env python
import argparse    
parser = argparse.ArgumentParser()
parser.add_argument('--test', action='store_true')
parser.add_argument('method', metavar='METHOD', nargs=argparse.OPTIONAL, default=None)
parser.add_argument('url', metavar='URL',)
parser.add_argument('items', metavar='REQUEST ITEM', nargs=argparse.ZERO_OR_MORE)


$ python args.py POST --test example.org
usage: args.py [-h] [--test] [METHOD] URL [REQUEST ITEM [REQUEST ITEM ...]]
args.py: error: unrecognized arguments: example.org

merwok commented Jan 25, 2013

Hm. I see that you’re not using subparsers probably because all commands have the same interface. There are a handful of open argparse bugs about parsing at the moment, maybe this is one of them. I’ll try to find time to check. Thanks for the reply.

@jakubroztocil jakubroztocil added the cli label Sep 7, 2014


jakubroztocil commented Feb 29, 2016

The general limitation is that --options cannot be placed between positional arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment