# `jadpo rename`

Rename a declaration or field everywhere.

Rename a declaration or a field (areas 14 and 18): at its declaration and every place code names it, the fields copied from it with `pick:` among them, moving the file named after it. The identity registry (database/identities.jadpo_record) records the name it was born with, so a stored field keeps its column and an entity its table, and the records the rename changes are written again. A new name already in use, or one that isn't a name for its kind, is refused before anything changes; a rename whose result would have an error the project didn't have changes nothing and shows that error. Name a field after its entity or type (`Invoice.amount`); its new name is its own (`total`).

```text
jadpo rename <name> <new-name>
```

## Arguments

- `name`: The declaration or field to rename, as code writes it
- `new-name`: Its new name

## On every command

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

`jadpo rename --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"rename"`), `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
# Rename an action, its file and every call
jadpo rename greet salute
# Rename a stored field, keeping its column
jadpo rename Invoice.amount total
```

## Errors

- [`cli.rename_arguments`](/docs/errors/cli.rename_arguments.md): A `jadpo rename` command names a declaration or field the project doesn't have, one it doesn't rename, or a new name that is taken or isn't one
- [`toolchain.artifact_write_failed`](/docs/errors/toolchain.artifact_write_failed.md): A file Jadpo writes for you, such as a record, couldn't be written, usually because it or its folder is read-only
- [`toolchain.project_not_found`](/docs/errors/toolchain.project_not_found.md): You ran a command that works on a project in a folder with no `app.jadpo`, in it or in any folder above it
