Metadata-Version: 2.5
Name: lineout-cli
Version: 0.2.0
Summary: Render Lineout diagram JSON files to SVG, PNG or JPG
Project-URL: Homepage, https://lineout.app
License-File: src/lineout/_assets/fonts/LICENSE.txt
Requires-Python: >=3.10
Requires-Dist: mini-racer>=0.12
Requires-Dist: resvg-py>=0.5
Provides-Extra: jpg
Requires-Dist: pillow>=10; extra == 'jpg'
Description-Content-Type: text/markdown

# lineout-cli

Render diagram JSON files exported from [Lineout](https://lineout.app) to SVG,
PNG or JPG. Arrows are routed with the same engine as the editor, so the output
matches the app.

## Install

The package is `lineout-cli`; the command and the Python module are `lineout`.

```bash
uv tool install "lineout-cli[jpg]"                                    # global `lineout` command
uvx --from lineout-cli lineout architecture.json -o architecture.png # one-off run
pip install "lineout-cli[jpg]"                                        # as a library
```

The `jpg` extra adds JPG output. Don't install `lineout`: that name on PyPI is
an unrelated package.

## Command line

```bash
lineout architecture.json                          # writes architecture.svg
lineout architecture.json -o architecture.png      # format from the suffix
lineout architecture.json -o out.jpg --theme dark
cat architecture.json | lineout - -f png -o - > architecture.png
```

| Option | Description |
| --- | --- |
| `-o, --output` | Output file, or `-` for stdout. Defaults to the input name with the format suffix. |
| `-f, --format` | `svg`, `png` or `jpg`. Defaults to the output suffix, else `svg`. |
| `-t, --theme` | `light` (default) or `dark`. |
| `--transparent` | No background. SVG and PNG only. |
| `-s, --scale` | Pixel ratio for PNG and JPG. Defaults to 2. |

## Python

```python
from lineout import render

png = render(open("architecture.json").read(), "png", theme="dark")
svg = render({"nodes": [...], "arrows": [...]})
```

`render` accepts a JSON string, bytes or a dict and returns bytes. Invalid
documents raise `lineout.LineoutError` with the path of the offending field.

## Updates

Each Lineout release publishes a new `lineout-cli`. Once a day the `lineout`
command checks PyPI for a newer version and, when there is one, prints a line
on stderr with the command to upgrade:

```bash
uv tool upgrade lineout-cli
```

The check waits at most two seconds, stays quiet when PyPI can't be reached and
is off when `LINEOUT_NO_UPDATE_CHECK` or `CI` is set. Its result is cached in
`~/.cache/lineout` (`~/Library/Caches/lineout` on macOS,
`%LOCALAPPDATA%\lineout` on Windows).

## Development

The package bundles the TypeScript renderer from the repository root. Build the
assets before building or running the package:

```bash
pnpm build:python                                        # from the repository root
uv tool install --editable "./packages/python[jpg]"      # once
uvx lineout architecture.json -o architecture.png        # uses the installed tool
```

The editable install reads the Python sources and `_assets/` straight from the
repository, so edits and `pnpm build:python` take effect on the next run.
Avoid `uvx --from ./packages/python`: uv caches that build and does not pick
up later changes. Remove the tool with `uv tool uninstall lineout-cli`.

Don't publish by hand. `pnpm release` in the app repository sets `version` in
`pyproject.toml`, and the release workflow builds the assets and publishes the
package to PyPI.
