# Lists

## Commands

`legato lists` prints every list, with its entries and the pages that check it.

`legato lists set <name> [--if-missing] [file|-]` creates a list, or replaces the entries of one you have. The input is one entry per line, or a JSON array of strings, up to 64 KB. Leave out the file, or give `-`, to read stdin. With `--if-missing`, a list that already exists is kept as it is.

A name is 1–48 characters: `a–z`, `0–9` and `-`, starting with a letter or digit.

`legato lists delete <name>` deletes a list. This can't be undone. A list that doesn't exist is refused with `not_found`.

Answers and refusals are JSON on stdout. Success exits with status 0, and a refusal with status 1. See [Lists](https://legatobar.com/docs/lists.md).

## Examples and success output

```bash
printf '%s\n' 'example.com' | legato lists set allowed-hosts --if-missing -
legato lists
legato lists delete allowed-hosts
```

The first command creates a list named `allowed-hosts`, unless you already have one. The last command deletes `allowed-hosts`, so leave it out if the list was yours before.

For a new list that no page checks yet, the first command prints:

```json
{
  "created" : true,
  "list" : {
    "entries" : [
      "example.com"
    ],
    "name" : "allowed-hosts",
    "reads_addresses" : false,
    "sent_to" : [

    ],
    "status" : "ready",
    "used_by" : [

    ]
  }
}
```

If the list was already there, `created` is `false`, `kept` is `true`, and `list` is the list as it was saved.

`legato lists` prints `{"lists": [...]}`, with each list in the same form.

`lists delete` prints `deleted`, which is the list's name, and `list`, which is `null`. If a page still checks the deleted list, `list` shows it with the status `not_set`.
