Metadata-Version: 2.3
Name: whirligig
Version: 1.0.0
Summary: Spin a colorful ASCII wheel of fortune in your terminal, from the CLI or Python
Keywords: wheel,spinner,terminal,ascii,random,picker
Author: GabeBecker2048
License: MIT License
         
         Copyright (c) 2026 Gabriel Becker
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Environment :: Console
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
Classifier: Topic :: Games/Entertainment
Requires-Python: >=3.10
Project-URL: Changelog, https://github.com/GabeBecker2048/whirligig/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/GabeBecker2048/whirligig
Project-URL: Issues, https://github.com/GabeBecker2048/whirligig/issues
Project-URL: Source, https://github.com/GabeBecker2048/whirligig
Description-Content-Type: text/markdown

# whirligig

[![PyPI](https://img.shields.io/pypi/v/whirligig)](https://pypi.org/project/whirligig/)
[![Python versions](https://img.shields.io/pypi/pyversions/whirligig)](https://pypi.org/project/whirligig/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/GabeBecker2048/whirligig/blob/main/LICENSE)
[![CI](https://github.com/GabeBecker2048/whirligig/actions/workflows/test.yml/badge.svg)](https://github.com/GabeBecker2048/whirligig/actions/workflows/test.yml)

![whirligig spinning a wheel of lunch options and landing on Burgers](https://raw.githubusercontent.com/GabeBecker2048/whirligig/main/demo/demo.gif)

<sub>Recorded from the real thing: `whirligig Pizza Sushi Tacos Thai "Chicken Wings" Poke Burgers`.</sub>

**Let the wheel decide.** whirligig spins a colorful ASCII wheel of fortune in
your terminal and lands on one of your choices: what's for lunch, who reviews
the PR, heads or tails. It's a CLI and a one-function Python library.

- A proper spin: the arm sweeps the wheel, slows down, and holds on the winner.
- Scripting-safe: the animation plays on your terminal, but stdout is only the
  chosen label, so `LUNCH=$(whirligig ...)` just works.
- Weight the odds by repeating a label; read labels from a file or a pipe; or
  spin a ready-made wheel (`coin`, `dice`, `clock`, `alphabet`).
- Zero dependencies. Python 3.10+ on Linux, macOS and Windows 10+.

## Try it

No install needed if you have [uv](https://docs.astral.sh/uv/) or
[pipx](https://pipx.pypa.io/):

```sh
uvx whirligig Pizza Sushi Tacos Thai "Chicken Wings" Poke Burgers
```

## Install

```sh
pip install whirligig    # or: uv tool install whirligig
```

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

## CLI

Pass the choices as arguments, quoting any that contain spaces:

```sh
whirligig Pizza Sushi Tacos Thai "Chicken Wings" Poke Burgers
```

Labels can repeat, and each copy is its own slot on the wheel, so
`whirligig Pizza Pizza Sushi` lands on Pizza twice as often. Copies of a label
share one color, so they read as one choice spread across the wheel.

| 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          |
| `-p`, `--preset` | —       | `coin`, `dice`, `clock`, `alphabet` or `random` |

```sh
whirligig -d 0.3 Yes No Maybe               # milk the suspense
whirligig -r 6 -d 0.02 heads tails          # just flip the coin already
whirligig -p dice                           # a ready-made wheel
whirligig -p random                         # surprise me
whirligig -f lunch.txt                      # one label per line; blank lines are skipped
grep -v alice teammates.txt | whirligig     # piped input works too (alice is on vacation)
ls ~/Desktop | whirligig                    # 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:

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

The captured value is the bare label: no color codes, 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 and returns the label it lands on:

```python
import whirligig

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

It takes the CLI's knobs as keyword arguments: `radius` (default `10`) and
`delay` (default `0.1`). The call blocks while the wheel animates; pass
`delay=0` to skip straight to the result:

```python
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)`.

> **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.

## Contributing

Issues and pull requests are welcome. The project is managed with
[uv](https://docs.astral.sh/uv/):

```sh
uv sync                                  # create .venv from uv.lock
uv run pytest                            # the test suite
uv run whirligig -r 6 -d 0 heads tails   # the fastest way to eyeball a render change
```

CI runs the suite on Python 3.10 to 3.14 across Linux, macOS and Windows.
[CLAUDE.md](https://github.com/GabeBecker2048/whirligig/blob/main/CLAUDE.md)
explains how the code fits together, and
[CHANGELOG.md](https://github.com/GabeBecker2048/whirligig/blob/main/CHANGELOG.md)
what changed in each release.

## License

MIT, see [LICENSE](https://github.com/GabeBecker2048/whirligig/blob/main/LICENSE).
