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

Multiple args being passed via CLI not consumed properly #190

Open robcxyz opened 10 months ago

robcxyz commented 10 months ago

When parsing multiple args passed via cli, we aren't properly consuming them and an error is raise even though the hook has multiple arg mappers. Issue is when we parse the args in run_declarative_hook, we iterate through the args and first check if the arg is a ref to a method, upgrade the hook if it is, then in the same loop evaluate_args which does not properly consume the arg and thus we are left with args. Issue has to do with the following:

  1. evaluate_args -> this does not pop the first consumed arg - only the last one
  2. run_declarative_hook -> this runs evaluate_args multiple times in a loop and thus only consumes the last arg but is not suitable for many args

Solution could be:

  1. Break up evaluate_args into evaluate_single_arg and force it to consume each arg
  2. In run_declarative_hook - only run evaluate_single_arg since there is already a loop needed to do the method upgrade

As some house cleaning, also should breakup the sections of run_declarative_hook into evaluate_dcl_hook_kwargs/args to make it more legible. evaluate_dcl_hook_args will mirror evaluate_args in that it loops through the args but doesn't upgrade a hook if it is a method.