Open mathbunnyru opened 2 years ago
doit has the concept of "commands" and "tasks". list
is a "command", so not suitable to be used as default_tasks
The default command is run
. That allows you you to write doit my_task
without having to explicitly specify the command as doit run my_task
.
Simply switching the default command to list
would not work well as doit my_task
would simply use the list
command and just "list" the task.
But I guess it could be easily special-case doit
without any parameters to execute list
while any other parameter/option would switch back to have run
as default.
I have seen people define the "default" task just to print a help message, like Use "doit list" to see available tasks or
doit helpfor available commands
.
I do not think it is worth the trouble to implement what you are suggesting...
But if anyone is willing to work on that, it should be easy to implement. Look at doit_cmd.py:DoitMain.run()
.
What I do is something like this:
def task(func):
func.create_doit_tasks = func
return func
DOIT_CONFIG = {
'default_tasks': ['_list'],
}
@task
def _list():
return dict(actions=["doit list"])
Then using just doit
will list all other tasks I have.
... Update: just read that you mentioned
I tried to create a task in dodo.py, which calls dodo list itself, but it won't work, because it needs to lock the DB.
So, I'm not sure my approach is equivalent to that tentative
Right now,
default_tasks
should contain tasks from the dodo.py configuration. Sometimes, there are projects, which do not have a good default. If would be nice to have"default_tasks": ["list"]
, so when I typedoit
, I get a nice description of available commands.Describe alternatives you've considered
.
is called (https://stackoverflow.com/questions/2057689/how-does-make-app-know-default-target-to-build-if-no-target-is-specified). I can for example have a nicehelp
command.dodo list
itself, but it won't work, because it needs to lock the DB.