CLI โ
Roll dice directly in your terminal with the RPG Dice Roller CLI. Use it to make individual rolls, roll several expressions at once, or play an interactive dice game.
Install โ
Install the CLI globally using npm:
npm install -g @dice-roller/cliThis makes the roller command available in your terminal.
Roll dice โ
Pass a dice notation to roller:
roller '4d6'You can also roll several expressions in one command, separated by spaces:
roller '2d10' '7d%' '5dF'In Bash, put each notation argument in single quotes to pass spaces and shell characters such as ! and > through to the CLI.
roller '4d6 # roll description'
roller '4d6d1!>=3'All supported dice notation is available in the CLI.
Rolling dice is the default command, so roller '4d6' and roller roll '4d6' are equivalent.
Options โ
roller <notation..> [options]| Option | Description | Default |
|---|---|---|
-s, --separator | Text used to separate the output of multiple rolls. | "; " |
-e, --engine | Choose crypto, mersenne, nativeMath or xoroshiro128plus. | nativeMath |
--seed | A signed 32-bit integer seed for mersenne or xoroshiro128plus. Supply the engine with --engine. | |
-f, --format | Choose string, json, base64 or object. The object format displays a JavaScript object for inspection. | "string" |
--result-only | With string output, print only the combined total. | false |
--color, --no-color | Force or disable ANSI styling for text rolls. | Automatic |
Text rolls use colour when the output terminal supports it. Piped or redirected output is plain text by default. Set NO_COLOR or use --no-color to turn off styling. Exports and --result-only totals are always plain.
Examples โ
Use the Mersenne Twister engine with a seed for repeatable rolls. See random number generators for details.
roller '4d6' --engine=mersenne --seed=415Print just the total.
roller '2d20' --result-onlyExport the roll history as JSON or Base64-encoded JSON.
roller '6d8*4' --format=json
roller '6d8*4' --format=base64Play an interactive game โ
Start an interactive dice game:
roller playOptions โ
| Option | Description |
|---|---|
--players | Player names, separated by spaces. |
--count | The number of players. |
--color, --no-color | Force or disable ANSI styling for displayed rolls. |
Examples โ
Start a game with four players:
roller play --count=4Start a game with two players named Barbara and Ian:
roller play --players=Barbara IanSet the number of players and name only the first:
roller play --count=2 --players=SusanHelp and version โ
Show the available commands and options:
roller --helpShow help for the interactive game:
roller play --helpDisplay the installed CLI version:
roller --versionYou can also use -V instead of --version.
Upgrade from CLI v1 โ
- Exports use the RPG Dice Roller v6 schema. JSON exports now have
type: "history"and a top-levelrollsarray in place oflog. Each roll contains aresulttree. The same schema applies to Base64 and object output. Update scripts that read the old structure. The format namesJSON,BASE_64andOBJECTare still accepted. - Engine names and seeded sequences have changed. Use
mersennein place ofMersenneTwister19937andcryptoin place ofnodeCryptoorbrowserCrypto. A v1 seed can produce different rolls in v2. - Check your Node.js version against the installation requirements before upgrading.