Skip to content

gunshi / default / ArgSchema

Interface: ArgSchema

An argument schema This schema is similar to the schema of the node:utils. difference is that:

  • required property and description property are added
  • type is not only 'string' and 'boolean', but also 'number', 'enum', 'positional', 'custom' too.
  • default property type, not support multiple types

Properties

PropertyTypeDescription
choices?string[] | readonly string[]The allowed values of the argument, and string only. This property is only used when the type is 'enum'.
default?string | number | booleanThe default value of the argument. if the type is 'enum', the default value must be one of the allowed values.
description?stringA description of the argument.
multiple?trueWhether the argument allow multiple values or not.
negatable?booleanWhether the negatable option for boolean type
parse?(value) => anyA function to parse the value of the argument. if the type is 'custom', this function is required. If argument value will be invalid, this function have to throw an error. Throws An Error, If the value is invalid. Error type should be Error or extends it
required?trueWhether the argument is required or not.
short?stringA single character alias for the argument.
toKebab?trueWhether to convert the argument name to kebab-case.
type"string" | "number" | "boolean" | "positional" | "enum" | "custom"Type of argument.

Released under the MIT License.