# Global flags and output

These flags work with every command.

## grayspar

Deploy your apps and share them like a Google Doc.

```sh
grayspar [flags] <command>
```

| Flag | Description |
| --- | --- |
| `--version` | Show the version. |
| `--json` | Answer in JSON, for scripts and agents. |
| `--team <slug>` | Which of your teams to work in. |
| `--project <name>` | Which project to act on, instead of the linked one. |
| `--no-color` | Print without colour. |
| `-h, --help` | Display help for command. |

## Choosing a project

A command acts on the project `--project` names. Without that flag, the command acts on the project the folder is linked to, looking upward through the parent folders the way Git finds a repository. Without a link, the command asks you to select a project. Without a terminal, the command refuses and names `--project`.

## Exit codes

| Code | Meaning                                                      |
| ---- | ------------------------------------------------------------ |
| 0    | The command did what you asked.                              |
| 1    | The command didn't do what you asked, including any refusal. |
| 130  | Ctrl+C stopped the command.                                  |

## What --json prints

With `--json`, results go to standard output as JSON and messages go to standard error, so the output is safe to parse.

A list or a read prints what Grayspar answered. A change prints a receipt with its status. `grayspar deploy` prints the project, its address, the variables it sent and left out, and how the deployment ended:

```json
{
  "project": "<project-name>",
  "url": "https://<project-name>.grayspar.com",
  "variables": { "sent": [], "leftOut": [] },
  "status": "live",
  "deployment": "…"
}
```

`grayspar logs --json` prints one JSON object per line.

A refusal prints `status`, an `error` code and a `message`. When a flag would answer it, the refusal also carries `supply_with`, the flag to add:

```json
{
  "status": "error",
  "error": "needs_a_name",
  "message": "This team already has a project called <project-name>.\nName the project with --name.",
  "supply_with": "--name"
}
```

## Environment

Set `NO_COLOR` or pass `--no-color` to print without colour. Colour and the spinner also stay off in a pipe and with `--json`.