How can I have argparse only parse commands that come after a positional argument?
Aka if I have the command pythonfile.py -d dir -e test pos_cmd_1 -d
How can I have it so that the first -d is parsed by argparse, and anything after the positional command is parsed by that command itself (read pos_cmd_1 -d as a single argument basically)
So that the argument list would be
- pythonfile.py
- -d dir
- -e test
- pos_cmd_1 -d -s -etc
So anything before the positional command would be optional. And anything after the positional command would be part of the positional command itself.
Edit: When trying to run the command with double dashes, it tells me that the arguments that come after aren't recognized.
pythonfile.py -d testdir -e test -- command -d -s
It says -d -s are unrecognized arguments instead of bundling them with the command.
pythonfile.py -d dir -e test -- pos_cmd_1 -dat least it's clear where options stop - Jean-François Fabre-dbe parsed as my command if it comes before the compose command (up/start/kill/etc) but if it comes after, it would be part of the docker command. Sopython.py -d test up -dwhere the second-dwould be parsed by docker. - cclloyd--, which often appears for "...then pass these arguments to whatever that calls". - jonrsharpepythonfile.py -d dir -e test "pos_cmd_1 -d"- VPfB