# ParserOptions

Available options for the Caporal internal parser. Arguments must be referenced by their position (0-based) and options by their name (short or long) in boolean, string and variadic parser options.

# Hierarchy

  • ParserOptions

# Properties

# alias

alias: Record‹string, string›

Option aliases map.


# autoCast

autoCast: boolean

Enable or disable autocasting of arguments and options. Default to true.


# boolean

boolean: string | number[]

List of Arguments and {@link Options Options} to be casted as booleans. Arguments must be referenced by their position (0-based) and options by their name (short or long).

Example

import { parseArgv } from "caporal/parser"

parseArgv({
 boolean: [2, 'sendEmail']
})

// ./my-cli-app first-arg second-arg 3rd-arg --sendEmail=1
// -> "3rd-arg" will be casted to boolean as well as "--sendEmail"

# ddash

ddash: boolean

Double-dash (--) handling mode. If true, the parser will populate the ParserResult.ddash property, otherwise, arguments will be added to ParserResult.args.


# string

string: string | number[]

List of Arguments and {@link Options Options} to be casted as strings. Arguments must be referenced by their position (0-based) and options by their name (short or long).

Example

import { parseArgv } from "caporal/parser"

parseArgv({
 string: [1]
})

// ./my-cli-app first-arg 2
// -> second arg "2" will be casted to string instead of number

# variadic

variadic: string | number[]

List of variadic Arguments and {@link Options Options}, meaning that there value is an Array.

Arguments must be referenced by their position (0-based) and options by their name (short or long).

Example

import { parseArgv } from "caporal/parser"

parseArgv({
 variadic: [1]
})

// ./pizza order margherita regina --add sausages --add basil
{
  args: ['order', ['margherita', 'regina']]
  options: {
    add: ['sausages', 'basil']
  }
}