# `jadpo fmt`

Format source files.

Rewrite Jadpo files in the one layout the formatter owns: indentation, spacing, blank lines and one member per line. In a project it first fixes each file's `use` lines: adds a missing import, removes an unused one and sorts them. With --layout it also moves each declaration another file uses into a file of its own, as layout.promotion_required asks. With --check, change nothing and fail if any file would change. Without a path, the project is found by walking up to app.jadpo.

Also: `jadpo format`.

```text
jadpo fmt [path]
```

## Arguments

- `path` (optional): A file or folder instead of the whole project

## Flags

- `--check`: Report unformatted files and change nothing
- `--layout`: Also make the moves promotion asks for

## On every command

- `--json`: Print data for tools instead of text
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo fmt --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"fmt"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# Format the project you are in
jadpo fmt
# Make the moves layout.promotion_required asks for, then format
jadpo fmt --layout
# Check formatting without changing anything, as CI does
jadpo fmt --check
# Format one file
jadpo fmt app.jadpo
```

## Errors

- [`cli.fmt_arguments`](../errors/cli.fmt_arguments.md): Format command has invalid arguments
