# `Plushie.Automation.File`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/automation/file.ex#L1)

Parser for `.plushie` automation files.

The `.plushie` format is a superset of iced's `.ice` test script format,
adding Plushie-specific instructions like `assert_text` and `assert_model`.

## Format

    app: MyApp.Counter
    viewport: 800x600
    theme: dark
    backend: mock
    -----
    click "#increment"
    expect "Count: 1"
    screenshot "counter-at-1"

`backend` selects which renderer mode the runner starts.
`viewport` is used as the default capture size for `screenshot`
instructions. The full parsed header is also forwarded to `app.init/1`
under the `:script` option when run through `Plushie.Automation.Runner`.

`theme` is script metadata only. It is available to the app through
`init(opts[:script])` if the app wants to interpret it, but the runner does
not force renderer or widget themes on your behalf.

See `Plushie.Automation.Runner` for execution.

# `header`

```elixir
@type header() :: %{
  app: module() | nil,
  viewport: {non_neg_integer(), non_neg_integer()},
  theme: String.t(),
  backend: Plushie.Automation.backend_mode()
}
```

# `instruction`

```elixir
@type instruction() ::
  {:click, String.t()}
  | {:type_text, String.t(), String.t()}
  | {:type_key, String.t()}
  | {:press, String.t()}
  | {:release, String.t()}
  | {:move, String.t()}
  | {:move_to, non_neg_integer(), non_neg_integer()}
  | {:toggle, String.t(), boolean() | nil}
  | {:select, String.t(), String.t()}
  | {:slide, String.t(), number()}
  | {:expect, String.t()}
  | {:screenshot, String.t()}
  | {:assert_text, String.t(), String.t()}
  | {:assert_model, String.t()}
  | {:wait, non_neg_integer()}
```

# `t`

```elixir
@type t() :: %{header: header(), instructions: [instruction()]}
```

# `parse`

```elixir
@spec parse(content :: String.t()) :: {:ok, t()} | {:error, String.t()}
```

Parses `.plushie` automation source from a string.

# `parse_file`

```elixir
@spec parse_file(path :: String.t()) :: {:ok, t()} | {:error, String.t()}
```

Parses a `.plushie` automation file from a path.

---

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