Class: MassargNumber
option.MassargNumber
An option that can be passed to a command.
This type of option parses a number, and fails if it is not a valid number.
Example
massarg(options).option({
name: 'number',
description: 'A number',
defaultValue: 0,
aliases: ['n'],
type: 'number',
})
Hierarchy
-
MassargOption
<number
>↳
MassargNumber
Constructors
constructor
• new MassargNumber(options
): MassargNumber
Parameters
Name | Type |
---|---|
options | Omit <{ name : string ; description : string ; aliases : string [] ; defaultValue? : any ; array? : boolean ; required? : boolean ; isDefault? : boolean ; hidden? : boolean ; outputName? : string ; parse? : Parser <ArgsObject , number > }, "parse" > |
Returns
Overrides
Defined in
Properties
name
• name: string
Inherited from
Defined in
description
• description: string
Inherited from
Defined in
defaultValue
• Optional
defaultValue: number
Inherited from
Defined in
aliases
• aliases: string
[]
Inherited from
Defined in
parse
• parse: Parser
<ArgsObject
, number
>
Inherited from
Defined in
isArray
• isArray: boolean
Whether this option can be used multiple times. Any passed values will end up in an array instead of each usage overwriting the existing value.
Inherited from
Defined in
isRequired
• isRequired: boolean
Whether this option is required. Failing to specify this option will throw an error.
Inherited from
Defined in
isDefault
• isDefault: boolean
Inherited from
Defined in
outputName
• Optional
outputName: string
Inherited from
Defined in
Methods
fromTypedConfig
▸ fromTypedConfig<T
, A
>(config
): MassargOption
<T
, ArgsObject
>
Create a typed option from a configuration. Currently supports number
options which
are automatically transformed from string
to number
.
Type parameters
Name | Type |
---|---|
T | unknown |
A | extends ArgsObject = ArgsObject |
Parameters
Name | Type |
---|---|
config | Object |
config.name | string |
config.description | string |
config.aliases | string [] |
config.type | undefined | "number" |
config.defaultValue | any |
config.array | undefined | boolean |
config.required | undefined | boolean |
config.isDefault | undefined | boolean |
config.hidden | undefined | boolean |
config.outputName | undefined | string |
config.parse | undefined | Parser <A , T > |
Returns
Inherited from
Defined in
parseDetails
▸ parseDetails(argv
, options
, prefixes
): ArgvValue
<number
>
Parameters
Name | Type |
---|---|
argv | string [] |
options | ArgsObject |
prefixes | Prefixes |
Returns
ArgvValue
<number
>
Overrides
MassargOption.parseDetails
Defined in
getOutputName
▸ getOutputName(): string
Returns the key which this option outputs to in the final object.
Returns
string
Default
The camelCase version of this option's name.
Can be overridden with {@link outputName}.
Inherited from
Defined in
helpString
▸ helpString(): string
Get the help string for this option
Returns
string
Inherited from
Defined in
isMatch
▸ isMatch(arg
, prefixes
): boolean
Returns true if the flag (including any prefixes) matches the name or aliases
Parameters
Name | Type |
---|---|
arg | string |
prefixes | Prefixes |
Returns
boolean
Inherited from
Defined in
qualifiedNames
▸ qualifiedNames(prefixes
): QualifiedNames
Return the finalized names that will cause this option to match.
Parameters
Name | Type |
---|---|
prefixes | Prefixes |