Open smarie opened 5 years ago
Your example can be written like this:
DOIT_CONFIG = {'default_tasks': ['mytask']}
def task_mytask():
return {
# 'name': 'mysubtask',
'params': [{
'name': 'myparam',
'short': 'p',
'long': 'myparam',
'default': 'param_default',
}],
'actions': ["echo myparam is %(myparam)s"],
'title': lambda t: str(t.actions[0]) % t.options,
'verbosity': 2,
}
It is trivial to write your own, and does not require changes in doit core.
Said that, I would not oppose to a change in title_with_actions
.
Thanks for the tip ! Even if users can customize many things, I guess that they prefer not to do so, so as to keep their code readable. So I'll try to propose a PR.
Consider the following
dodo.py
file:Executing it yields:
You can notice that the title created for the action is not correct: one would expect to see
Cmd: echo myparam is param_default
, in other words one would expect that this title, since it is created after task instantiation, actually represents what will be executed.I see two ways to fix this:
title_with_actions
method. This would force us to write an ugly if/elif statement in it to support all kind ofBaseAction
subtypes.__str__
in allBaseAction
subtypes directly. For example forCmdAction
: