just icon indicating copy to clipboard operation
just copied to clipboard

Add a function to call `just` executable that preserves all CLI-passed parameters

Open nyurik opened this issue 2 years ago • 4 comments

I often have to run just_executable() while also passing all of the parameters passed by the user. As you can see in this example, forwarding parameters to sub-task is highly error-prone and cumbersome. Instead, I think it would be better to have a just_forward() function that automatically handles this param-escaping logic:

param1 := "default for param1"
param2 := "default for param2"

nested_just := just_executable() + " param1=" + quote(param1) + " param2=" + quote(param2)

foo:
  # ...
  {{ nested_just }} bar ...
  # ...

bar:
  # ...

nyurik avatar Dec 14 '23 23:12 nyurik

This is definitely desirable, but I don't know how to make it work well enough to be comfortable landing it. For example, if you want to override some flags, then those new flags would conflict fi if they were already given on the command line.

casey avatar Dec 15 '23 06:12 casey

off the top of my head, weird syntax style:

just_forward()             = keep context
just_forward(foo, bar)     = only forward variables foo and bar
just_forward_without(foo)  = keep context except for param "foo"

nyurik avatar Dec 15 '23 07:12 nyurik

goes into the same thing as: #1772

gabyx avatar Dec 21 '23 00:12 gabyx

@gabyx thx, good link. The only difference here is that forwarding not only escapes a series of arguments, but also properly handles variable assignments -- just var1=bar var2=1 target1 arg1 arg2

nyurik avatar Dec 21 '23 04:12 nyurik