# CLI

The `rimfe` command line sets up a repository and works with checks from the terminal. It needs Node.js 20 or newer.

## Set up a repository

Run this at the root of the repository, or anywhere inside it:

```sh
npx @rimfe/cli init
```

`init` finds your docs the same way setup in the dashboard does. It recognises Docusaurus, MkDocs, Starlight, Mintlify, GitBook, Sphinx, Antora, Nextra, VitePress, Fumadocs and Fern, and plain `docs` folders. It then writes a [`.rimfe.json`](https://docs.rimfe.com/configuration/rimfe-json) at the repository root:

```json
{
  "$schema": "https://rimfe.com/schema/rimfe.json",
  "docsGlobs": ["README.md", "website/docs/**/*.{md,mdx}"]
}
```

- It reads the files git tracks (or the folder, outside git), never sends anything anywhere and needs no sign-in.
- Test fixtures are never taken for your docs.
- With no docs found, it writes a starting guess (`README.md` and `docs/`) and says so.
- In a terminal, it shows what it found and asks before writing. In CI or a script, or with `--yes` (`-y`), it writes without asking.
- `--print` shows the file without writing it.
- An existing `.rimfe.json` is left alone unless you confirm, or pass `--force`.

Then:

1. Check the globs, and commit the file to your default branch.
2. Install [Rimfe on GitHub](https://github.com/apps/rimfe) on the repository.
3. In the repository's settings in Rimfe, set **Documentation scope** to **.rimfe.json at the PR base** on the **Advanced** tab.

## Work with checks

Install the CLI, sign in once, then list and act on checks:

```sh
npm install -g @rimfe/cli
rimfe login
rimfe checks --view action
```

| Command | What it does |
| --- | --- |
| `rimfe login` | Signs in through the browser, where you pick the workspace and whether the CLI may make changes. |
| `rimfe logout` | Forgets this computer's sign-in. |
| `rimfe repos` | Lists the workspace's repositories. |
| `rimfe checks` | Lists pull requests with their latest check. `--repo owner/name` limits it to one repository, `--view` picks `action`, `all`, `pass` or `skipped`, `--page n` pages through. |
| `rimfe check <check-id>` | Shows a check's findings. |
| `rimfe start <owner/name> <pull-request>` | Starts a check of an open pull request. |
| `rimfe decide <check-id> <finding-id> <decision>` | Records `accepted`, `dismissed`, `resolved` or `reopened` on a finding. `--reason text` adds why. |

- `--json` prints the raw results, for scripts.
- `start` and `decide` change things, so they need write access, which you grant when you sign in, and they ask before they run.
- A start counts toward the [manual check limit](https://docs.rimfe.com/reference/limits), like **Run check** in the dashboard.
- `rimfe --version` prints the version, and `rimfe <command> --help` lists a command's options.

The sign-in is kept in your user config folder, readable by you only. `rimfe logout` removes it.
