citty icon indicating copy to clipboard operation
citty copied to clipboard

Create shared args for all `subCommands` in main

Open fu050409 opened this issue 1 year ago • 2 comments
trafficstars

Describe the feature

Hi!

Sometimes we need to create global args because all subcommands will use them. It's complex and duplicate if we define them in all of our subCommands' defination.

Can we provide an api to create shared args?

Additional information

  • [X] Would you be willing to help implement this feature?

fu050409 avatar Jul 05 '24 12:07 fu050409

image maybe you can call the generateArgs function to do this outside citty

zuixinwang avatar Jul 15 '24 09:07 zuixinwang

There's a workaround for this.

const sharedArgs = { argName: { type: 'string', ... } }

export default defineCommand({ args: { ...sharedArgs, otherArg: { ... } } })

HigherOrderLogic avatar Oct 07 '24 11:10 HigherOrderLogic