Closed Spiffyk closed 1 year ago
Oh, only now do I realize that Poetry itself also throws the --
pseudo-argument away, so that's quite a bummer, and renders this almost useless :(
Since I believe this behaviour is errorneous on poetry
's side as well, I submitted an issue to their tracker as well: https://github.com/python-poetry/poetry/issues/8361
Alright, so it's a known issue on poetry
's side and has a straightforward workaround using poetry run -- [whatever]
. Would there be interest in having this behaviour adjusted on poethepoet
's side then?
Hi @Spiffyk, thanks for the PR.
I'm not sure I really understand the issue you're encountering. I take it your using poe via the poetry plugin and that's where you're getting behaviour different that what you expect, but this is due primarily to how poetry handles arguments?
Could you provide an example of a task to reproduce the issue?
Here's how argument parsing it intended to work today wrt --
.
For tasks without args
declared it is treated like any other argument, .e.g.
[tool.poe.tasks.asdf]
cmd = "echo"
$ poe asdf hello -- goodbye
Poe => echo hello -- goodbye
hello -- goodbye
$ poetry poe asdf hello -- goodbye
Poe => echo hello -- goodbye
hello -- goodbye
For tasks with args
declared it is parsed to indicate that the remaining arguments should be append to to the end of the command (for a cmd task specifically), (documented here, covered by the test you modified) e.g.
[tool.poe.tasks.asdf]
cmd = "echo $foo and "
args = ["foo"]
$ poe asdf --foo hello -- goodbye
Poe => echo hello and goodbye
hello and goodbye
$ poetry poe asdf --foo hello -- goodbye
Poe => echo hello and goodbye
hello and goodbye
Does this make sense? Can you demonstrate how this doesn't work with your use case?
Oh, I see. The issue was with poetry all along and I somehow thought the same problem was present in poethepoet. I re-tested it locally with the poetry run -- [cmd ...]
workaround and it seems to work.
Closing the PR as it is invalid.
This commit makes it so that when a user passes the
--
pseudo-argument to a task, it is preserved for further processing by the task itself. Various commands may use--
to e.g. pass arguments to another subprogram, or (e.g. in the case ofargparse
) to differentiate positional arguments from options.Note that this change potentially breaks compatibility, as some already implemented tasks may rely on the
--
pseudo-argument being dropped, in fact, one of the tests was written that way. However, I strongly believe this is actually a bug and I decided to update the test as well.