Feature request: ability to print some data about each action before it gets executed.
If my task has multiple actions (and verbosity==2), I can't tell which output came from which action (assuming that the actions all succeed). Some way to tell which output comes from which action would be great. Printing e.g. the shell command that will be run, before running it, would be a good way to achieve this.
If you write echo 123
as part of a recipe in a Makefile (using GNU make), the following is printed:
+ echo 123
123
This is great for debugging purposes, so that you will know what command has produced the output you are seeing. The +
symbol prefix makes it easy to tell what is the command, and what is the output from the command.
Perhaps this could be verbosity level 3?
For CmdAction
, it should be easy to print the action that will be executed by Popen
, just before it gets executed.
For PythonAction
, it is not as clear what should be the output. Perhaps a str
representation of the python-action and it's args and kwargs...
I have tried using the title
keyword for the task, with a custom title printer:
# dodo.py
import doit
def show_cmd(task):
result = "EXECUTING " + task.name
for action in task.actions:
if isinstance(action, doit.action.CmdAction):
result += "\n+ " + action.expand_action()
if isinstance(action, doit.action.PythonAction):
result += f"\n+ {action.py_callable.__name__}(*{action.args}, **{action._prepare_kwargs()})"
return result
def py_action(a=1, b=3):
print(f"in py_action: {a=}, {b=}")
def task_custom_display():
return {"actions": ["echo abc efg", (py_action, (2,), {"b": 4})], "title": show_cmd}
However, when I run doit --verbosity 2
on this dodo.py
file, the results are out of order:
$ doit --verbosity 2
. EXECUTING custom_display
+ echo abc efg
+ py_action(*(2,), **{'b': 4})
abc efg
in py_action: a=2, b=4
I still cannot tell where the stdout from the first action ("abc efg") end, and the stdout from the second action ("in py_action: a=2, b=4") begins. This is why I'm requesting this feature.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too