pydoit / doit

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

Tasks as global arguments #365

Closed Armoken closed 4 years ago

Armoken commented 4 years ago

I want to use tasks using the syntax of global arguments. And I am not understand why this is not possible.

def task_argument_name():
    def action():
        globals()["GLOBAL_VAR"] = True

    return {
        "basename": "--argument-name",
        "verbosity": 2,
        "actions": [action],
    }
[armoken:~/D/curriculum-vitale-template] in env:[.venv] at git:(master⚡) ➜ doit list
--argument-name   

But I am getting an error:

[armoken:~/D/curriculum-vitale-template] in env:[.venv] at git:(master⚡) ➜ doit --argument-name
ERROR: Error parsing Command: option --argument-name not recognized (parsing options: ['--argument-name'])

Environment

  1. OS: Linux
  2. python version: 3.8.2
  3. doit version: 0.32.0

Upvote & Fund

Fund with Polar

schettino72 commented 4 years ago

The leading -- in the task name makes doit command parser think it is a parameter. Tasks names can NOT start with a -.

Armoken commented 4 years ago

Tasks names can NOT start with a -.

@schettino72, is this restriction specified by Doit team, or I can try to fix code of command parser to get functionality what I need?