# How commands work

> coline <area> <verb>, workspaces, JSON output, dry runs, exit codes, and any action by name.

Source: https://docs.coline.app/cli/commands

Every action in Coline is a command named after it: `tasks.relations.add` is `coline tasks relations add`, and `tasks.listDeleted` is `coline tasks list-deleted`. A few commands are made for the terminal, like `coline today`, `coline inbox`, `coline tasks add` and `coline mail send`.

`coline --help` lists the areas, `coline tasks --help` the commands in one, and `coline tasks create --help` one command's flags. The [reference](/cli/reference) has them all.

## Input

Each of an action's input fields is a flag:

```bash
coline tasks create -w acme --taskboard-id <id> --title "Ship the CLI"
```

Fields a flag can't hold, and any field at all, can go in `--json '{…}'`, or in a file with `--input <file>` (`-` reads stdin). A flag wins over the same field in JSON.

```bash
coline tasks create -w acme --json '{"taskboardId":"<id>","title":"Ship the CLI"}'
```

coline never asks a question when it isn't at a terminal. A missing value is an error that names the flag.

## Workspaces

`-w acme` runs a command in the workspace `acme`. It takes the slug or any Coline link inside the workspace. Without `-w`, commands use `COLINE_WORKSPACE`, then the workspace in this repository's trusted `.coline/config.json`, then the default you set with `coline workspace use`.

## Output

Without `--json`, results go to stdout and errors to stderr as plain sentences. With `--json`, a command prints exactly one object: success on stdout, failure on stderr.

```json
{ "ok": true, "data": { }, "summary": "Created ENG-42", "link": "https://coline.app/…", "next": ["coline tasks get ENG-42"] }
```

```json
{ "ok": false, "error": "…", "code": "WORKSPACE_FORBIDDEN", "retryable": false, "hint": "coline workspace use acme" }
```

| Flag                                  | What it does                                                  |
| ------------------------------------- | ------------------------------------------------------------- |
| `--json [fields]`                     | Print one JSON object; with field names, only those fields    |
| `--fields <list>`                     | Ask for only these fields, like `id,title,assignees.id`       |
| `--jq <expression>`                   | Filter the result's data with a jq expression                 |
| `--page-all`                          | Fetch every page; with `--json`, one object per line per page |
| `--ids-only`, `--count`, `--markdown` | Print only ids, only how many, or Markdown                    |
| `--web`                               | Open the result in Coline                                     |
| `--quiet`                             | Print nothing on success except the JSON you asked for        |

## Changes, dry runs and deleting

* `--dry-run` checks a command and shows what would run, and changes nothing.
* `-y` accepts defaults and skips ordinary questions. It is not consent to delete.
* An action that deletes or overwrites runs only with `--confirm`. Without it, coline says what would be removed and exits with code 2.
* Mail and invites to people outside wait for your approval. See [What waits for you](/cli/approvals).

## Exit codes

| Code | Meaning                                                                       |
| ---- | ----------------------------------------------------------------------------- |
| 0    | Done                                                                          |
| 1    | A server or unexpected error                                                  |
| 2    | Usage or bad input, including a delete without `--confirm`                    |
| 3    | Sign-in needed, or it ended                                                   |
| 4    | Signed in, but not allowed                                                    |
| 5    | Not found                                                                     |
| 7    | Rate limited                                                                  |
| 8    | Network                                                                       |
| 9    | This version of coline is too old: run `coline update`                        |
| 10   | Waiting for your approval in Coline. Not a failure: the link is in the output |
| 130  | Stopped with Ctrl-C                                                           |

## Any action by name

`coline schema` lists every action with its effect, and `coline schema tasks.create` shows what one takes and returns. `coline do` runs any action by its name with its exact input:

```bash
coline do tasks.create -w acme -f taskboardId=<id> -f title="Ship the CLI"
coline do tasks.list -w acme --json '{"taskboardId":"<id>"}' --fields id,title
```

`-f` adds a text field and `-F` a typed one (`true`, `false`, `null`, numbers, JSON, or `@file`). For a route that isn't an action, `coline api` sends a request with your sign-in:

```bash
coline api GET /api/v1/me/workspaces
```

## Links and names

`coline open mail` opens a part of Coline, `coline open <link>` any link, and `coline open ENG-42`, `coline open '#general'` or `coline open @ada` a task, a channel or a person. Commands made for the terminal take the names the app shows, like `coline tasks edit ENG-42`.

## Apps, sites, Upstream and computers

Coline's other command lines run through `coline` with the same sign-in:

| Command                                                                  | What it runs                                                             |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
| `coline apps create`, `dev`, `push`, `publish` and `coline sites deploy` | `coline-app`, which builds apps and sites                                |
| `coline upstream <anything>`                                             | `upstream`, Upstream's command line. `coline auth login` signs it in too |
| `coline computers up`, `down`, `screen`                                  | `coline-computer`, which connects this computer to your account          |

When `upstream` or `coline-computer` isn't installed, coline prints the command that installs it.

## Settings

`coline config` reads and changes settings in `~/.config/coline/cli/config.json`. A repository can hold a `.coline/config.json` with a workspace and a profile. coline ignores it until you run `coline config trust-local` in that repository, and again whenever the file changes. It can never set the server or a token.

`coline completion zsh` (or `bash`, `fish`, `powershell`) prints shell completion for every command.
