Skip to content
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

Including square brackets in arguments does not pass to poe #191

Open
stephen-spar opened this issue Dec 15, 2023 · 2 comments
Open

Including square brackets in arguments does not pass to poe #191

stephen-spar opened this issue Dec 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@stephen-spar
Copy link

  • version: 0.24.4
  • system: macOS

Issue

When including square brackets in an argument (either positional or non-positional), it seems to break how poe sends along the arguments to the actual task.

Reproduction

# pyproject.toml

[tool.poe.tasks.hello]
cmd = "echo $name"
args = [{ name = "name", positional = true }]

This works as expected:

poe hello "world"
Poe => echo world
world

This does not:

poe hello "world[extra]"
Poe => echo

Use Case

I have a sequence command to install poetry packages (poe add) which runs poetry add $package, and then a second command to sync them with my dev container:

[tool.poe.tasks.add]
sequence = [{ cmd = "poetry add $package" }, { ref = "sync-dev-deps" }]
args = [{ name = "package", positional = true }]

All good if I'm trying to install something like django or numpy, but for something with "extra" packages (ex. django-anymail[mailgun]), I'm not able to utilize this command and need to fall back to poetry add "django-anymail[mailgun]".

Hopefully this isn't documented anywhere - if it is, feel free to point me in that direction and close the issue! Thanks so much for the awesome package, fits my needs exactly.

@nat-n nat-n added the bug Something isn't working label Dec 16, 2023
@nat-n
Copy link
Owner

nat-n commented Dec 16, 2023

Hi @stephen-spar, thanks for reporting this issue.

It looks like the square brackets from the argument are getting picked up in the cmd task as glob pattern to be interpreted. I agree that this is surprising, and I'm going to leave this issue open to think about how to improve it.

This is a quirk of the design at the intersection of how cmd tasks implement shell like features (including parameter expansion and glob expansion) and how they interpolate CLI arguments as env vars.

I think you can get around this by quoting the parameter expansion in your task definition like so:

[tool.poe.tasks.add]
sequence = [{ cmd = "poetry add \"$package\"" }, { ref = "sync-dev-deps" }]
args = [{ name = "package", positional = true }]

The logic here is similar to bash, where you can disable glob expansion with quotes.

@stephen-spar
Copy link
Author

@nat-n ah, thank you for the workaround - works a treat. Appreciate your quick response, and again, thanks for the phenomenal tool, it vastly improves the DX of the project I'm working on. Keep up the great work!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants