just icon indicating copy to clipboard operation
just copied to clipboard

Recipe attribute to customize string separating variadic parameters?

Open laniakea64 opened this issue 1 year ago • 2 comments

Related to https://github.com/casey/just/issues/647#issuecomment-2329480131

Currently just always separates variadic parameters with the string " ". Now that just has escaping of arbitrary characters, should there be a recipe attribute to customize the variadic separator string for individual recipe?

This could allow shebang recipes to work with variadic parameters as lists where the values may contain spaces: the variadic delimiter string could be set to something vanishingly unlikely, e.g. null character \u{0}, and the shebang recipe's interpreter could split on that and internally work with a list variable.

For linewise recipes, this would make more opportunity for just to have a quote_each function like suggested in the other issue, its signature could be quote_each(string, input_delimiter_string) and it return each quoted string separated by space.

laniakea64 avatar Sep 15 '24 16:09 laniakea64

This is a really interesting thought. We could have a separate function, or we could give quote() an optional second argument, which is an optional input_delimiter. Although, an advantage a separate function like quote_each, would be that if the delimiter is omitted, it could default to \0, so you wouldn't need to specify the separator in multiple places.

This does feel super hacky though. I would really prefer doing what was proposed in #208, which is to allow values which are lists of strings, so that quoting can interact correctly with var args. But, I've been talking about that for a while and still haven't done it 😅

casey avatar Sep 17 '24 08:09 casey

+1 for #208

Not having to do something like this: just recipe command '--arg="value with spaces"' is just about the last thing I need to for my just interface to be seamless.

bckohan avatar Mar 10 '25 17:03 bckohan