I'm using docopt and python 2.7. I want to implement something similar to --
in vim. From man vim
:
-- Denotes the end of the options. Arguments after this will be handled as a file
name. This can be used to edit a filename that starts with a '-'.
Thankfully, docopt already implements this, but it gives me an extra '--'
in my argument list. For example, take this short python script:
"""Usage:
doc.py FILE [ARGUMENTS ... ]
doc.py FILE [options] [ARGUMENTS ... ]
Options:
-h --help Show this screen.
-d Debug mode.
-f FILE Open FILE
-w FILE Log to FILE
--safe Do not allow shell access
"""
from docopt import docopt
def main():
print(args["ARGUMENTS"])
if __name__ == "__main__":
args = docopt(__doc__, version="V alpha 0.1")
main()
If I call this with
python doc.py file.txt -- 1 2 3 -w
I get this:
['--', '1', '2', '3', '-w']
I would expect it to give:
['1', '2', '3', '-w']
What am I doing wrong?