pydoit / doit

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

task_params does not work when using basename #434

Open frozax opened 2 years ago

frozax commented 2 years ago

Hi,

The task_params decorator does not work when the task is using basename. The parameters are detected, but not replaced in the task parameter in python.

dodo.py

from doit import task_params

@task_params([{"name": "param", "short": "p", "long": "param", "default": "default"}])
def task_test1(param):
    return { 'actions':[f"echo task_test1 {param}"] }

@task_params([{"name": "param", "short": "p", "long": "param", "default": "default"}])
def task_test2(param):
    return { 'basename': 'test_other', 'actions':[f"echo task_test2 {param}"] }

Execution

> doit -v2 test1 --param p1 test_other --param p2
.  test1
task_test1 p1
.  test_other
task_test2 default

Execution 2

> doit -v2 test_other --invalid p2
ERROR: Error parsing Task: option --invalid not recognized (parsing options: [CmdOption({'name':'param', 'short':'p','long':'param' })]). Got: ['--invalid', 'p2']

Environment

  1. OS: Windows 10
  2. python version: 3.7.3
  3. doit version: 0.34.2

Fund with Polar

tom-varga commented 2 years ago

On my way.

-Tom On Jul 31, 2022, 12:34 PM -0400, Francois Guibert @.***>, wrote:

Hi, The task_params decorator does not work when the task is using basename. The parameters are detected, but not replaced in the task parameter in python. dodo.py from doit import task_params

@task_params([{"name": "param", "short": "p", "long": "param", "default": "default"}]) def task_test1(param): return { 'actions':[f"echo task_test1 {param}"] }

@task_params([{"name": "param", "short": "p", "long": "param", "default": "default"}]) def task_test2(param): return { 'basename': 'test_other', 'actions':[f"echo task_test2 {param}"] } Execution

doit -v2 test1 --param p1 test_other --param p2 . test1 task_test1 p1 . test_other task_test2 default Execution 2 doit -v2 test_other --invalid p2 ERROR: Error parsing Task: option --invalid not recognized (parsing options: [CmdOption({'name':'param', 'short':'p','long':'param' })]). Got: ['--invalid', 'p2'] Environment

  1. OS: Windows 10
  2. python version: 3.7.3
  3. doit version: 0.34.2

If someone has a quick idea on how to fix this, feel free to share a patch and I'll be happy to test it. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>