nat-n / poethepoet

A task runner that works well with poetry.
https://poethepoet.natn.io/
MIT License
1.46k stars 59 forks source link

[Feature request] Implicit print #61

Closed XF-FW closed 2 years ago

XF-FW commented 2 years ago

Hello there,

I'm trying to add something like this:

# pyproject.toml (lines 48-49)
[tool.poe.tasks]
get_random_secret_key = { script = "django.core.management.utils:get_random_secret_key()" }

The function however, returns a string and does not print its result. Would it be possible to have an option to print the return values of a given function?

Thank you.

ThatXliner commented 2 years ago

Changing https://github.com/nat-n/poethepoet/blob/e9cabc322191982aaa8a1d5f6f8d0581d0027666/poethepoet/task/script.py#L57 should be sufficient

XF-FW commented 2 years ago

Sounds about right and I wouldn't mind contributing with a PR, but I'm not sure on how I should handle the configuration.

ThatXliner commented 2 years ago

The title of this issue is “implicit print” so maybe you would like it to print the return value if the return value is not None

how I should handle the configuration.

I believe it’s self.options? Not too sure but you should try that

nat-n commented 2 years ago

Hi @XF-FW, thanks for the feedback.

I see how that would be useful. I would accept a PR to enable something along the lines of:

[tool.poe.tasks]
get_random_secret_key = { script = "django.core.management.utils:get_random_secret_key()", print_result = true }

Check the contributing guide. You'll need to register an option for the script task type (see how it's done for the sequence task type) and a test case here.

nat-n commented 2 years ago

I've implemented this feature on the development branch and it will be included in the next release.