# `mix ash_grant.check_permissions`
[🔗](https://github.com/jhlee111/ash_grant/blob/v0.22.0/lib/mix/tasks/ash_grant.check_permissions.ex#L1)

Checks stored permission strings against the application's resources.

Permission strings live in your roles table, seeds or migrations — the compiler
never sees them. This task runs `AshGrant.PermissionValidation.check_all/2`
over a file of them, so a pipeline can refuse a release whose code no longer
matches the strings it will meet (a renamed action, scope or field group, or a
plain typo).

## Usage

    mix ash_grant.check_permissions FILE [options]

`FILE` is either:

  * a `.json` file holding an array of permission strings, or an object whose
    values are arrays of them (`{"editor": ["post:*:read:always"]}`) — the keys
    are shown next to each finding; or
  * any other file, read as one permission per line. Blank lines and lines
    starting with `#` are skipped.

Pass `-` to read a newline list from standard input:

    psql -At -c "select unnest(permissions) from roles" | mix ash_grant.check_permissions -

## Options

  * `--otp-app` - Check against the resources in this application's
    `:ash_domains`. Without it, every AshGrant resource in the started
    applications' `:ash_domains` is used.
  * `--format`  - `text` (default) or `json`.

## Exit codes

  * 0 - No issue of severity `:error`. Warnings are printed but do not fail.
  * 1 - At least one `:error`.
  * 2 - Usage error (missing file, unreadable input, invalid option).

# `run_cli`

```elixir
@spec run_cli([String.t()], keyword()) ::
  {:ok, String.t(), 0} | {:error, String.t(), 1 | 2}
```

Pure entry point used by both `run/1` and the test suite.

Returns `{:ok | :error, output_string, exit_code}`. Accepts a `:resources`
option in `check_opts` so tests can pin the resources without an OTP app.

---

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