obfs-flash-client doesn't allow intermixed positional and optional arguments
I was playing with a torrc
for obfs-flash and I found that obfs-flash-client doesn't allow options to come between positional arguments:
works: obfs-flash-client 2334 :9000
works: obfs-flash-client 2334 :9000 --fp-arg=-4
works: obfs-flash-client --fp-arg=-4 2334 :9000
doesn't work: obfs-flash-client 2334 --fp-arg=-4 :9000
The "doesn't work" error is
$ ./obfs-flash-client 2334 --fp-arg=-4 :9000
usage: obfs-flash-client [-h] [--fp-arg ARG] PORT [REMOTE:PORT]
obfs-flash-client: error: unrecognized arguments: :9000
I expected intervening options not to affect non-option arguments, like other commands I'm used to. It seems like the behavior is inherent to argparse:
- Issue 14191: argparse doesn't allow optionals within positionals
- Python argparse: Combine optional parameters with nargs=argparse.REMAINDER
If you agree that this is worth changing, a potential workaround is
- http://bugs.python.org/issue14191#msg155185 (and maybe other messages in that bug) optparse works the way I expect, but it is deprecated.