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

Allow list to be used in default_tasks #421

Open
mathbunnyru opened this issue Mar 20, 2022 · 2 comments
Open

Allow list to be used in default_tasks #421

mathbunnyru opened this issue Mar 20, 2022 · 2 comments

Comments

@mathbunnyru
Copy link

mathbunnyru commented Mar 20, 2022

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 type doit, I get a nice description of available commands.

Describe alternatives you've considered

Fund with Polar
@schettino72
Copy link
Member

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 help for 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().

@andersonbrands
Copy link

andersonbrands commented Jan 9, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants