cmd-ts
cmd-ts copied to clipboard
Adding ability to accept unknown arguments
Usecase:
Say I'm using cmd-ts
to wrap another CLI call.
And I don't want to map each of the 2nd CLI's arguments, but just forward them from the original call.
something like:
cmdTs.command({
name: 'runner',
acceptUnknownArguments: true,
args: {
myArg: flag({
type: boolean,
long: 'my-arg',
}),
handler: ({ myArg, unknownArgs }) => {
if (myArg) {
execa(`node ./otherCli ${unknownArgs.join(' ')}`)
}
},
},
})
I'm stuck with this exact use case. Would you consider a pull request with the feature ?
The rest
parser (which I need to document) should make this possible. However, there’s a design issue in cmd-ts that I need to really think on how to fix for this to work correctly: help
and version
flags are circuit breakers and are parsed before the user config. Need to think about how to fix it to allow passing them as free arguments