Open ItsDrike opened 1 year ago
Hi @ItsDrike,
I agree this is an issue, but I've not managed to find a good solution yet. One difficulty is that I haven't found a robust way to pass arguments to a shell child process (to populate $@ within the shell) where the script content is being passed via stdin (which is how shell tasks work). Rethinking shell tasks as discussed in #64 might help, but that's a way off on the roadmap.
Thinking allowed here, maybe just having a way to capture extra arguments (either when there are no args defined, or when provided after the --
on the command line) and being able to specifically inject them at a certain point in a command rather than append them to the end is all that's needed? Need to think this through a bit...
I'm open to ideas.
That said, one imperfect solution that might just work for you is to define a positional arg on your task that accepts multiple values. For example given a task like:
[tool.poe.tasks.show-args]
cmd = """
python -c "import sys; print(sys.argv[1:])" being $all_args end
"""
args = [{ name = "all_args", positional = true, multiple = true }]
And a command like:
poe show-args middle "multiple words" -- and then some
The result will be:
Poe => python -c import sys; print(sys.argv[1:]) begin middle multiple words end and then some
['begin', 'middle', 'multiple', 'words', 'end', 'and', 'then', 'some']
A couple of points to pay attention to:
I was hoping to migrate from Makefile to a better tool and found this library.
I found a similar limitation with regards to running command inside a docker container. For example when running Django commands, I have to do docker-compose run --rm server bash -c "python manage.py makemigrations"
but most of the commands need extra arguments to be passed. This is not possible with the tool because we need to put the command inside quotes/double quotes.
I also used go-tasks
for a while and I think I am looking for something similar to {{.CLI_ARGS}}
(https://taskfile.dev/usage/#forwarding-cli-arguments-to-commands)
With shell scripts, it's possible to do something like:
python -m robot --pythonpath . -d ./outptut "$@" tests
, so that when you call a script, the passed arguments are forwarded to the command in a specific location.However with poe a task like:
Any passed arguments will simply be appended to the end of the command. This isn't ideal, as some CLI tools only support usage like:
robot [options] paths
, which means any positional arguments left after the options are interpreted as paths. This means that running for example:robot --pythonpath . ./tests -d ./output
wouldn't work, and I'd get an error that it couldn't find-d
as a path.I'd love to see a feature that would allow for me to pass arguments to a specific place in my command.