pastel icon indicating copy to clipboard operation
pastel copied to clipboard

Command unable to specify a "version" option.

Open mattrothenberg opened this issue 1 year ago • 1 comments

Hello!

I would like one of my commands to have a version option so that users can look up a resource by an optional version ID.

I've set my options as such:

export const options = zod.object({
	owner: zod.string().describe('Model owner'),
	name: zod.string().describe('Model name'),
	version: zod.string().optional().describe('Model version'),
	silent: zod.boolean().optional().describe('Silence output'),
});

I'm noticing, however, that no matter what the user passes via --version, the underlying app version is returned and the command never runs.

I'm not sure whether this is unexpected behavior, or something I'm doing silly. Probably the latter :) Let me know if I can provide any more detail.

mattrothenberg avatar Jun 21 '23 20:06 mattrothenberg

Hey @mattrothenberg, yeah, version is defined by Pastel automatically and it always prints a program version when specified. I see two options here:

  1. Expose an config option for disabling a default version option. However, this means that CLI won't be able to display its version via -v or --version, which most users expect.

  2. Same as above, but a config option to disable version per command, rather than for an entire CLI.

  3. Disable the default version option when a command specifies its own version, like you do. However, this is the kind of implicit behavior I usually try to avoid, but it would be the most effortless solution for you.

I'll think more about this and I'd also appreciate your thoughts on what is the ideal behavior you'd expect here 😉

vadimdemedes avatar Jun 22 '23 06:06 vadimdemedes