Boolean option
Learn how to define boolean options for templates.
Boolean options accept a true or false value, making them ideal for feature flags and configuration switches.
Example
The following template prints a greeting with an optional uppercase toggle:
template.json5
{ "$schema": "https://schema.croct.com/json/v1/template.json", "title": "Greeting", "description": "Prints a greeting.", "options": { "uppercase": { "type": "boolean", "description": "Whether to print in uppercase.", "default": false } }, "actions": [ { "name": "print", "semantics": "info", "message": "${options.uppercase ? 'HELLO!' : 'Hello!'}" } ]}You can pass --uppercase to enable the flag, or --no-uppercase to explicitly disable it:
npm
npx croct@latest use template.json5 --uppercaseThis prints HELLO!. Without the flag, it prints Hello!.
Properties
The following list describes the properties for boolean options:
- typestring
The option type. Always boolean for boolean options.
- descriptionstring
A description displayed when prompting the user.
- default(optional)boolean
The default value used when the user does not provide one.