Closed nakrovati closed 1 month ago
I'd like to invoke rebuild-single like that: npm run rebuild-ci keyed/qwik keyed/vanillajs
(as before).
With a small fix in package.json this would translate to node cli.js rebuild-single --ci keyed/qwik keyed/vanillajs
.
The current implementation would require node cli.js rebuild-single --ci true --frameworks keyed/qwik keyed/vanillajs
I tried to play with commander to get this working but I lost patience. Can you take a look at it?
It is better to make the "rebuild-ci" script either like this: node cli.js rebuild-single --ci
and call nr rebuild-ci -f keyed/svelte...
; or like this: node cli.js rebuild-single --ci -f
(pass the -f
flag as the last argument) and call nr rebuild-ci keyed/svelte...
.
It can be done, but options
in commander.js is an object with flags, and when passing an array of arguments as in the code below, you can't swap them around and will have to strictly specify the order of flags and arguments in action
in cli.js
.
If you do as it was before only with commander.js without extra code, there are 2 problems:
program
.command("rebuild-single")
.option("--ci [boolean]", "", false)
.argument("<...frameworks>", "frameworks")
.action((options, ci) => {
console.log(options, ci);
// rebuildSingleFramework(options;)
});
This code will work when called as it should, but you will need to specify --ci true
(extra -true
) in the script, you cannot pass flags in random order and you cannot pass other flags after the frameworks argument.
program
.command("rebuild-single")
.argument("<...frameworks>", "frameworks")
.option("--ci [boolean]", "", false)
.action((options, ci) => {
console.log(options, ci);
// rebuildSingleFramework(options;)
});
You won't be able to pass arguments through flags in random order and will have to specify --ci
when calling the script.
P.S: you can abbreviate --ci true
as just --ci
, and --frameworks
to -f
.
cli
directory.takeWhile.d.ts
with jsdoc types fortakeWhile
function.node copy.js
). Now the same-named functions from CLI commands are exported, and all commands can be called viacli.js
.And some other improvements.