# `mix plushie.connect`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.6.0/lib/mix/tasks/plushie.connect.ex#L1)

Runs a Plushie application that connects to an already-listening
renderer via a Unix domain socket or TCP port.

## Usage

    mix plushie.connect MyApp                              # socket from env, token from env/stdin
    mix plushie.connect MyApp /tmp/plushie.sock            # explicit socket
    mix plushie.connect MyApp :4567                        # explicit TCP port
    mix plushie.connect MyApp /path.sock --token TOKEN     # explicit token

## How it connects

The renderer (`plushie --listen`) creates a socket and either spawns
this task (via `--exec`) or prints connection info for manual use.

**Launched by `--listen --exec`**: The renderer sets `PLUSHIE_SOCKET`
and `PLUSHIE_TOKEN` in the environment and writes a JSON negotiation
line to stdin. The task reads the token from the environment first,
falling back to stdin if env vars weren't forwarded (e.g., over SSH).

**Manual connect**: The user copies the socket path and token from
the renderer's output and provides them as CLI arguments.

## Token resolution (in order)

1. `--token` CLI flag
2. `PLUSHIE_TOKEN` environment variable
3. JSON line from stdin (1 second timeout): `{"token":"...","protocol":1}`
4. No token (connect without -- renderer decides if that's OK)

If the token is resolved from steps 1 or 2, stdin is not read.

## Socket resolution (in order)

1. Positional CLI argument after the module name
2. `PLUSHIE_SOCKET` environment variable
3. Error

## Options

  * `--token TOKEN` -- shared token for authentication
  * `--json` -- use JSON wire format instead of MessagePack
  * `--daemon` -- keep running after all windows close

---

*Consult [api-reference.md](api-reference.md) for complete listing*
