Number option

Learn how to define numeric options for templates.

Number options accept a numeric value, such as a port, a count, or a limit.

Example

The following template repeats a greeting a given number of times:

template.json5
{  "$schema": "https://schema.croct.com/json/v1/template.json",  "title": "Repeat greeting",  "description": "Prints a greeting a given number of times.",  "options": {    "times": {      "type": "number",      "description": "How many times to greet.",      "default": 1    }  },  "actions": [    {      "name": "print",      "semantics": "info",      "message": "${'Hello!\\n'.repeat(options.times)}"    }  ]}

You can pass the option directly as a flag:

npx croct@latest use template.json5 --times 3

This prints Hello! three times.

Properties

The following list describes the properties for number options:

type
string

The option type. Always number for number options.

description
string

A description displayed when prompting the user.

default(optional)
number

The default value used when the user does not provide one.