-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequences can't handle arguments :( #37
Comments
Hi @rjurney, thanks for the feedback! Yes, I skipped on supporting arguments for sequences the first time round for lack of clarity on how it could work without inelegance. I have a couple of ideas though. One way to achieve this would be to instead use the task graph feature discussed in #26, for which there is already an experimental implementation in pre-release. I say experimental because it's not really documented or well tested yet. So with the pre-release version of poethepoet I think you could do something like the following: [tool.poe.tasks]
setup-artifacts = "scripts/setup_artifacts.sh setup-poetry"
add = { cmd = "poetry add", "deps" = ["setup-artifacts"] } This example defines a minimalist task graph, with The other way is something I thought of recently but haven't yet tried would to build upon the named arguments feature (also in pre-release) and make [tool.poe.tasks]
setup-artifacts = "scripts/setup_artifacts.sh setup-poetry"
_poetry_add = "poetry add"
[tool.poe.tasks.add]
sequence = ["setup-artifacts", "_poetry_add $target"]
args = ["target"] Which would then be invoked as |
I have a similar issue. For simplicity, let's say I'd like to chain-run What I can do already is a general task for the whole project, like this: [tool.poe.tasks]
isort = "isort ."
black = "black ."
format = ["isort", "black"] OR statically specify files or folders [tool.poe.tasks]
format_this_specific_file_why_would_I_ever_do_this = [
{cmd = "isort ./src/util/error.py"},
{cmd = "black ./src/util/error.py"}
] But I cannot dynamically give a file or folder for both task to run on, like this: [tool.poe.tasks]
....
[tool.poe.tasks.format]
sequence = ["isort $target", "black $target"]
args = ["target"] Is there already a method I can use to get these desired results that I am missing? I can also imagine another solution for simple cases. Something like this: [tool.poe.tasks]
format = ["isort $1", "black $1"] Where |
Hello @Haffi921, I previously looked into supporting positional arguments (see #17), but haven't found a satisfactory way to do it that generalises well across use cases. The key difficulty is that shells don't let you arbitrarily set envvars like The example you gave with |
Hey @nat-n, thanks for the reply. That's a shame, it would be a really nice feature. However, I also feel as the Still I tried it and it doesn't seem to work. It literally says "Sequence task 'format' does not accept arguments 😁 Here is my [tool.poe.tasks]
test = "pytest ."
retest = "pytest . --lf"
[tool.poe.tasks.format]
sequence = ["isort $target", "black $target"]
args = ["target"] Here's the output: PS C:\...> poe format --target .
Poe the Poet - A task runner that works well with poetry.
version 0.11.0b5
Error: Sequence task 'format' does not accept arguments
USAGE
poe [-h] [-v | -q] [--root PATH] [--ansi | --no-ansi] task [task arguments]
GLOBAL OPTIONS
-h, --help Show this help page and exit
--version Print the version and exit
-v, --verbose Increase command output (repeatable)
-q, --quiet Decrease command output (repeatable)
-d, --dry-run Print the task contents but don't actaully run it
--root PATH Specify where to find the pyproject.toml
--ansi Force enable ANSI output
--no-ansi Force disable ANSI output
CONFIGURED TASKS
test
retest
format
--target Again tho, not a big issue. It's not like I need More so that I just wanted you to know it didn't work. And I definitely think it would be a nice feature! |
My bad! it's not there yet... 😣 I'm in the middle of refactoring some related code at the moment, I'll see if I can get to work while I'm at it. |
Ahh makes sense, yeah no worries |
@rjurney As of v0.11.0 (just released) you can now do something like: [tool.poe.tasks]
setup-artifacts = "scripts/setup_artifacts.sh setup-poetry"
[tool.poe.tasks.add]
sequence = [{ref="setup-artifacts"}, { cmd = "poetry add $package" }]
args = [{ name = "package", positional = true }] which could be invoked like: poe add moto I hope this works for you :) @Haffi921 Your example should work now too |
@nat-n Great! Well done, this is a cool feature! |
I've read the code and I can't find any way to make a sequence accept an argument. The code actually says to throw an exception if any extra arguments are given :(
I need to run the task
setup-artifacts
before I run the taskpoetry add
. Sincepoetry add
takes an argument I need to feed it to the last command in the list. This seems unsupported. I read the code and I get lost but this tells meSequenceTasks
don't accept arguments:poethepoet/poethepoet/task/sequence.py
Lines 53 to 72 in c5ac6cf
My
pyproject.toml
reads:I run
poe add moto
and I get:This makes me a sad panda :( What would I need to do to make
poe
take arguments to sequences? Maybe put an argument for them likeargs_to=2
to reference the command in the sequence?The text was updated successfully, but these errors were encountered: