pydoit / doit

CLI task management & automation tool
http://pydoit.org
MIT License
1.84k stars 175 forks source link

Commands don't work when DB file option is specified? #422

Closed jglogan closed 2 years ago

jglogan commented 2 years ago

dodo.py:

def task_hello():
    return {
        'doc': 'Print something.',
        'actions': [ 'echo Hello, world!' ]
    }

What I see:

% doit -f dodo.py list
hello   Print something.
% doit --db-file ${PWD}/doit-test.db -f dodo.py list
ERROR: Invalid parameter: "list". Must be a command, task, or a target.
Type "doit help" to see available commands.
Type "doit list" to see available tasks.

Is this expected behavior?

Environment

  1. OS: MacOS 12.3.1
  2. python version: 3.9.9
  3. doit version: 0.34.2

Upvote & Fund

Fund with Polar

schettino72 commented 2 years ago

Only task-loader options can be specified before a sub-command (i.e. list). Moving the option after the list should work.

doit  -f dodo.py list --db-file ${PWD}/doit-test.db

Sorry, documentation on this really needs some improvements...

jglogan commented 2 years ago

I was confused because I thought I'd need to handle subcommands separately from tasks, as I was using doit task-name to dispatch tasks. But, with doit run task-name I can apply the argument consistently. Thank you for your help!

schettino72 commented 2 years ago

Note that parsing CLI options is strict as not accepting unrecognized options. Configurations are more flexible in this aspect. You can specify an option to all commands, and those are options are ignored if they do not apply.

dodo.py

DOIT_CONFIG = {"dep_file": "doit-test.db"}