Skip to main content

Spin a colorful ASCII wheel of fortune in your terminal, from the CLI or Python

Project description

whirligig

PyPI Python versions License: MIT CI

Spin a colorful ASCII wheel of fortune in your terminal and let fate decide: what's for lunch, who reviews the PR, heads or tails.

whirligig spinning a wheel of lunch options and landing on Burgers

Try it

No install needed if you have uv or pipx:

uvx whirligig Pizza Sushi Mexican Thai "Chicken Wings" Poke Burgers

Install

pip install whirligig

Requires Python 3.10+, on Linux, macOS, or Windows 10+.

CLI

Pass the choices as arguments; quote any that contain spaces.

whirligig Pizza Sushi Mexican Thai "Chicken Wings" Poke Burgers

Labels can repeat: each copy is its own slot on the wheel, so repeating a label is an easy way to weight the odds — whirligig Pizza Pizza Sushi lands on Pizza twice as often. All copies of the same label share one color, so they read as one choice spread across the wheel.

Known quirk: wide characters — emoji, CJK — occupy two terminal columns where the wheel's geometry counts one, so a 🍕 label can bend the circle slightly. The spin works fine; the wheel just loses a little roundness.

flag default meaning
-r, --radius 10 radius of the wheel, in characters (2–100)
-d, --delay 0.1 seconds each frame is held; lower spins faster
-f, --file read labels from a file, one per line
whirligig -d 0.3 Yes No Maybe        # milk the suspense
whirligig -r 6 -d 0.02 heads tails   # just flip the coin already

A few wheels come ready-made — coin, dice, clock, and alphabet — and random spins one of them:

whirligig --preset dice
whirligig -p random          # surprise me

Keep a standing list in a file, one label per line, and spin it with -f. Blank lines are skipped:

whirligig -f lunch.txt

Piped input is read the same way, no flag needed (-f - also works):

grep -v alice teammates.txt | whirligig   # alice is on vacation
ls ~/Desktop | whirligig   # select a random file from your Desktop

Scripting

The wheel is drawn on your terminal, but stdout is just the choice — so you can watch the spin and capture the answer at the same time:

LUNCH=$(whirligig Pizza Sushi Mexican Thai "Chicken Wings" Poke Burgers)
echo "ordering $LUNCH"

The captured value is the bare label, with no color codes and no animation frames. With no terminal at all (in CI, or under whirligig ... &> file) the animation is skipped and only the choice is printed.

Python

whirligig.spin draws the same wheel:

import whirligig

result = whirligig.spin(["Pizza", "Sushi", "Mexican", "Thai", "Chicken Wings", "Poke", "Burgers"])

It returns the label the wheel landed on, and takes the CLI's knobs as keyword arguments: radius (default 10) is the wheel's size in characters, and delay (default 0.1) is the seconds each frame is held. The call blocks while the wheel animates; pass delay=0 to skip straight to the result:

result = whirligig.spin(["heads", "tails"], radius=6, delay=0)

Bad input raises ValueError: blank or multi-line labels, more labels than the radius can hold (the error suggests one that fits), or a terminal too small for the wheel. Full details live in help(whirligig.spin).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whirligig-0.4.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whirligig-0.4.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file whirligig-0.4.0.tar.gz.

File metadata

  • Download URL: whirligig-0.4.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for whirligig-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5bad49b97e6efde37ddef46f62fb7cb0137b83b86c73fbd2adb58438b163c8cf
MD5 7b4458ab2e4c82619f95058bb141a661
BLAKE2b-256 69bcde4082a89cdf97b6dc80c81818be736db0ac9b2554d2898f2b1bf98769da

See more details on using hashes here.

File details

Details for the file whirligig-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: whirligig-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for whirligig-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92ffdd19136120fa581e74ee3d7e4175ea423bb4115d99c9fdb0847e80e46786
MD5 6ac9c33b796f5856f893c17450980349
BLAKE2b-256 76a65635b0bcb07c00c5a35866e49fb8476ff66dd93f3efda6e985f7d8c70f8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page