# Configuration commands

These commands change how a service runs. Typing `grayspar env` or `grayspar volume` alone runs its `list` command. Setting or removing a variable, and adding or removing a volume, redeploy the service by themselves.

## grayspar env list

List the names of a service's variables.

```sh
grayspar env list [flags]
```

| Flag | Description |
| --- | --- |
| `-s, --service <name>` | Which service to read. |

## grayspar env set

Set variables on a service.

```sh
grayspar env set [flags] <pairs...>
```

| Argument | Description |
| --- | --- |
| `pairs` | Variables written as KEY=VALUE. |

| Flag | Description |
| --- | --- |
| `-s, --service <name>` | Which service to set them on. |

```sh
grayspar env set STRIPE_KEY=sk_test_123 LOG_LEVEL=debug --service api
```

## grayspar env remove

Remove variables from a service.

```sh
grayspar env remove [flags] <keys...>
```

| Argument | Description |
| --- | --- |
| `keys` | The names of the variables to remove. |

| Flag | Description |
| --- | --- |
| `-s, --service <name>` | Which service to change. |

```sh
grayspar env remove LOG_LEVEL --service api
```

## grayspar volume list

List the volumes of a project.

```sh
grayspar volume list [flags]
```

| Flag | Description |
| --- | --- |
| `-s, --service <name>` | Which service to read. |

## grayspar volume add

Add a volume to a service.

```sh
grayspar volume add [flags] <path>
```

| Argument | Description |
| --- | --- |
| `path` | The folder inside the service to keep, such as /app/data. |

| Flag | Description |
| --- | --- |
| `-s, --service <name>` | Which service keeps it. |

```sh
grayspar volume add /app/data --service api
```

## grayspar volume remove

Delete a volume and its data.

```sh
grayspar volume remove [flags] <path>
```

| Argument | Description |
| --- | --- |
| `path` | A folder the service keeps. |

| Flag | Description |
| --- | --- |
| `-s, --service <name>` | Which service keeps it. |
| `-y, --yes` | Remove it without asking. |

This command deletes the volume's data, and it needs the owner role.

```sh
grayspar volume remove /app/data --yes
```

## grayspar service set

Change a service's path, name or Dockerfile.

```sh
grayspar service set [flags] [name]
```

| Argument | Description |
| --- | --- |
| `name` | The service to change, left out when the project has one. |

| Flag | Description |
| --- | --- |
| `--path <path>` | Where the service answers at the project address. |
| `--no-path` | Reach the service only from the project's other services. |
| `--name <name>` | A new name for the service. |
| `--dockerfile <path>` | Build from this Dockerfile, from the root of the project. |
| `--no-dockerfile` | Build the way Grayspar found the service again. |

A change to a path or a name applies at once. A change to a Dockerfile applies at the next deploy.

```sh
grayspar service set api --path /v2
grayspar service set worker --no-path
grayspar service set api --name backend
grayspar service set api --dockerfile docker/api.Dockerfile
```

## grayspar service remove

Remove a service with its volume and variables.

```sh
grayspar service remove [flags] <name>
```

| Argument | Description |
| --- | --- |
| `name` | The service to remove. |

| Flag | Description |
| --- | --- |
| `-y, --yes` | Remove it without asking. |

This command stops the service and deletes its volume and variables, and it needs the owner role. A project keeps at least one service, so removing the last one means removing the project. A later deploy that finds the service's folder again makes a new service.

```sh
grayspar service remove worker --yes
```