unjs / citty

🌆 Elegant CLI Builder
Other
729 stars 23 forks source link

Support type `number` to args #138

Open onmax opened 5 months ago

onmax commented 5 months ago

Describe the feature

Description

Allow users to add a type number to the args. Citty will automatically parse the number and thrown an error if the string is invalid

Example

export default defineCommand({
  meta: {
    name: "Test",
    description: "A test command",
  },
  args: {
    len: {
      type: "number",
      description: "Limit len",
      default: 15
    },
  },
  run({ args }) {
    args.len // Type "number"
  },
});

Related to

This issue can be related to #87

Feedback

Is this a good feature we would like to add?

Additional information

janniks commented 3 months ago

This seems to be working (tested on latest main playground example)

Barbapapazes commented 2 months ago

related to https://github.com/unjs/citty/pull/73, https://github.com/unjs/citty/issues/23 and https://github.com/unjs/citty/issues/71

No release since the PR has been merged.

Barbapapazes commented 2 months ago

This seems to be working (tested on latest main playground example)

Indeed, it works now (but not released yet).