Metadata-Version: 2.4
Name: gum-wrapper
Version: 1.1.0
Summary: A typed Python wrapper for the gum CLI tool.
Project-URL: Homepage, https://github.com/yourname/gum-py
Project-URL: Repository, https://github.com/yourname/gum-py
Project-URL: Bug Tracker, https://github.com/yourname/gum-py/issues
Project-URL: gum upstream, https://github.com/charmbracelet/gum
Author-email: Your Name <you@example.com>
License: MIT
Keywords: charmbracelet,cli,gum,shell,terminal,tui
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
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: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Terminals
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: pydantic
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-mock>=3.14; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# gum-py

A typed Python wrapper for the [`gum`](https://github.com/charmbracelet/gum) CLI tool.

Build glamorous interactive shell scripts from Python — without writing a line of Go.

## Requirements

- Python 3.9+
- [`gum`](https://github.com/charmbracelet/gum#installation) on your `$PATH`
- [`pydantic`](https://docs.pydantic.dev/) ≥ 2.0

## Installation

```bash
pip install gum-py
```

Install `gum` itself via your package manager:

```bash
brew install gum          # macOS / Linux
winget install charmbracelet.gum  # Windows
```

## Quick start

```python
from gum import Gum

with Gum() as g:
    kind = g.choose(
        items=["fix", "feat", "docs", "chore"],
        header="Commit type",
    )
    scope   = g.input(placeholder="scope (optional)")
    summary = g.input(placeholder="Short summary", width=72)
    body    = g.write(placeholder="Extended description  (ctrl+d to finish)")

    if g.confirm(prompt="Commit?", default=False):
        import subprocess
        msg = f"{kind[0]}{f'({scope})' if scope else ''}: {summary}"
        subprocess.run(["git", "commit", "-m", msg, "-m", body])
```

Run the built-in demo:

```bash
python -m gum
# or, after pip install:
gum-demo
```

## Two calling styles

Every method accepts either **inline kwargs** (a config model is built internally) or an **explicit config object** (validated before the call):

```python
g = Gum()

# Style 1 — inline kwargs
selected = g.choose(items=["a", "b", "c"], height=5)

# Style 2 — config object
from gum import ChooseConfig
cfg = ChooseConfig(items=["a", "b", "c"], height=5)
selected = g.choose(cfg)
```

## Styling

Pass a `StyleOptions` instance to any `*_style` parameter:

```python
from gum import Gum, StyleOptions, BorderStyle, Align

g = Gum()
box = g.style(
    texts=["Bubble Gum (1¢)", "So sweet and so fresh!"],
    foreground="212",
    border=BorderStyle.DOUBLE,
    border_foreground="212",
    align=Align.CENTER,
    width=50,
    margin="1 2",
    padding="2 4",
)
print(box)
```

## Environment variables

`gum` supports `GUM_*` environment variables. Pass them via the `env` parameter
to have them apply to every call made through that instance:

```python
g = Gum(env={"GUM_INPUT_CURSOR_FOREGROUND": "#FF0"})
```

Explicit flags set through config objects always take precedence over env vars.

## Commands

| Method | gum command | Returns |
|---|---|---|
| `choose()` | `gum choose` | `list[str]` |
| `confirm()` | `gum confirm` | `bool` |
| `input()` | `gum input` | `str` |
| `write()` | `gum write` | `str` |
| `filter()` | `gum filter` | `list[str]` |
| `spin()` | `gum spin` | `str` |
| `style()` | `gum style` | `str` |
| `join()` | `gum join` | `str` |
| `format()` | `gum format` | `str` |
| `log()` | `gum log` | `None` |
| `file()` | `gum file` | `str` |
| `pager()` | `gum pager` | `None` |
| `table()` | `gum table` | `str` |

## Error handling

```python
from gum import Gum, GumNotFoundError, GumCommandError

try:
    g = Gum()
    name = g.input(placeholder="Your name")
except GumNotFoundError:
    print("gum is not installed — see https://github.com/charmbracelet/gum")
except GumCommandError as e:
    print(f"gum exited {e.returncode}: {e.stderr}")
```

## License

MIT
