cmd-ts icon indicating copy to clipboard operation
cmd-ts copied to clipboard

Adding ability to accept unknown arguments

Open DanielKag opened this issue 3 years ago • 2 comments

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(' ')}`)
			}
		},
	},
})

DanielKag avatar Nov 24 '21 12:11 DanielKag

I'm stuck with this exact use case. Would you consider a pull request with the feature ?

Toilal avatar Mar 04 '22 15:03 Toilal

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

Schniz avatar May 18 '22 06:05 Schniz