sudoblockio / tackle

Tackle is a programmable configuration language for building modular utilities, code generators, and CLIs with schema validation baked in.
Apache License 2.0
52 stars 2 forks source link

Args from base not being mapped to method #120

Open robcxyz opened 1 year ago

robcxyz commented 1 year ago

Given:

foo<-:
  target: str
  args: ['target']
  apply<-:
    exec:
      p->: print {{target}}

Ok:

tackle scratch.yaml foo apply --target bar -pf yaml

Error:

tackle scratch.yaml foo apply bar -pf yaml
tackle.exceptions.UnknownInputArgumentException: Error parsing input_file='scratch.yaml' 
The hook='apply' was supplied the arg='bar' and does not take any arguments. Exiting.

Comes from parser.py

elif hook.__fields__['args'].default == []:  # noqa
  raise.... 

Which is run before

    if 'args' in hook.__fields__:
        evaluate_args(args, arg_dict, Hook=hook, context=context)

Interestingly this works:

foo<-:
  target: str
  args: ['target']
  apply<-:
    args: ['target']
    exec:
      p->: print {{target}}