zx
zx copied to clipboard
Feature request: accept a minimist-like object of arguments in $`command`
Up to now, $`command ${arg}` processes:
- arrays (by substituting and quoting each of its items, then joining them using space characters),
- objects with a
stdoutproperty (by substituting them with the value ofstdout, then quoting it), - and any other value is "stringified" and quoted.
It would be interesting to also have a special treatment for objects that don't have a stdout property and which don't override toString (as in o.toString !== Object.prototype.toString). This kind of objects could be seen as minimist-like objects, and would be substituted like so:
$`command ${{
_: ['foo', 'bar'],
a: true,
bc: true,
d: 'value',
e: ['value1', 'value2'],
'-f': 'value',
'--': {
g: true
}
}}`
// $ command -a -bc --d value --e value1 --e value2 -f value foo bar -- -g
Interesting idea. Let me think about it.
Dropping this for inspiration purpose: https://github.com/lukeed/mri
@antonmedv I would like to take this up looks interesting.
I’m still not sure we need this.