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.5.0.tar.gz (9.6 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.5.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whirligig-0.5.0.tar.gz
  • Upload date:
  • Size: 9.6 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.5.0.tar.gz
Algorithm Hash digest
SHA256 17756cf94be420abba26988aee1bab09ed2f4db9798a5a387933f93e5cef8a5c
MD5 76793bf77c630c77d568604791142d64
BLAKE2b-256 b409734a20b59049195a35ff5c5823ddfab687e4fb8f93d3514a6e9b7c4e9b07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whirligig-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0858ee6c105c619e96be43c4989fa6b01ae935db60c819493f654bd369bb23a
MD5 cd817786661c7be1941159053fc08d38
BLAKE2b-256 6107f5e22a6e3d2bbcc8f81bfaf8c2f63d8b043f584ebcd467e8f5ff003e339e

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