# Commands

Every command of the Brewless command line client, with its arguments and options.


Every command that works on an environment takes the name of the environment as its first argument, such as `production`. Commands read `brewless.yml` in the current directory to know which application they are about.

## Project

### login

Sign this machine in to an organisation. See [Signing in](/cli/signing-in).

```bash
brewless login [organisation] [--no-browser]
```

### logout

Forget this machine's sign-in to an organisation.

```bash
brewless logout <organisation>
```

### init

Connect this project to an application at Brewless, write `brewless.yml`, add the environments the application should have and set them up.

```bash
brewless init [--organisation=] [--application=] [--framework=] [--php=] [--environments=] [--region=]
              [--database=] [--database-resource=] [--queue=] [--bucket] [--from-vapor] [--yes] [--force]
```

After the application, `init` asks:

1. which environments to add, `production` and `staging` unless you pick otherwise, and in which region;
2. for each one, which database: a new Serverless SQL Database, one that stands in your Scaleway project already, or none;
3. where its jobs wait: in that database, in a queue at Scaleway Queues, or nowhere;
4. whether it gets a private bucket for its files.

It then says what that comes to and, after one yes, makes it in your own accounts. Say no and it prints the `brewless provision` line that does the same later. What each choice makes is described under [Setting an environment up](/applications/applications-and-environments#setting-an-environment-up).

Without Scaleway connected the environments are added and nothing is asked; connect it and run `brewless provision`. Run without a terminal, `init` adds the environments `--environments=` names and sets them up only with `--yes`.

With a `vapor.yml` in the project, `init` offers to start from it. It writes a `brewless.yml` with every environment of `vapor.yml` and each setting Brewless has a key for, such as memory, timeouts, queues, the scheduler, build steps, deploy hooks as release commands, the database, the bucket and the domains, and prints once what it could not carry over. It then sets each environment you add up with a new database, a queue at Scaleway Queues and a bucket where Vapor had one. Nothing at Vapor or AWS is read or changed. Your variables, the data in your databases and the files in your buckets are yours to move; `init` lists them at the end, with a `brewless domain:add` line for every domain. See [Moving from Laravel Vapor](/getting-started/from-vapor).

| Option | What it does |
| --- | --- |
| `--organisation=` | The organisation the application belongs to |
| `--application=` | The slug of an application that exists already |
| `--framework=` | `laravel`, `symfony` or `generic`; detected from `composer.json` when left out |
| `--php=` | The PHP version to build for, such as `8.4`. See [PHP version](/deployments/deployments#php-version) |
| `--environments=` | The environments to add, such as `production,staging`; `none` adds none |
| `--region=` | Where new environments stand. See [Regions](/reference/regions) |
| `--database=` | For every new environment: `new`, `existing` or `none` |
| `--database-resource=` | The name of the existing database to use |
| `--queue=` | For every new environment: `database`, `sqs` or `none` |
| `--bucket` | Make a private bucket for the files of every new environment |
| `--from-vapor` | Start from the `vapor.yml` of this project without asking |
| `--yes` | Set the new environments up without asking first |
| `--force` | Overwrite an existing `brewless.yml` |

## Releases

### deploy

Deploy the current commit to an environment. Without an environment it deploys to `default-environment` from `brewless.yml`. First it does what `brewless.yml` asks of the environment's resources: it makes the environment when it does not exist yet, sets it up, and adds a database, queue or bucket it is missing. It names the domains of the file the environment does not answer on yet and asks before it adds them. See [Deployments](/deployments/deployments).

```bash
brewless deploy [<environment>] [--domains]
```

| Option | What it does |
| --- | --- |
| `--domains` | Add the domains of `brewless.yml` the environment does not answer on yet without asking. Without a terminal they are only added with this option |

From a pipeline, see [Deploying from a pipeline](/deployments/from-a-pipeline).

### plan

Show what `brewless.yml` asks for next to what stands now, per environment: what is the same (`=`), what would change (`~`), what would be added (`+`), what stays because the file leaves it out (`·`), what a deploy would refuse (`!`, with why), and what cannot be read (`?`). It changes nothing. When Brewless refuses the file, each reason comes with the line it is about. See [brewless.yml](/reference/brewless-yml).

```bash
brewless plan [<environment>]
```

### service:push

Build a service of `brewless.yml` with Docker on this machine and put it live in an environment. Needs Docker. See [Services](/running/services).

```bash
brewless service:push <environment> <service>
```

### releases

List the latest releases of an environment.

```bash
brewless releases <environment>
```

### rollback

Put the image of an earlier release live again. See [Rollbacks](/deployments/rollbacks).

```bash
brewless rollback <environment> [--release=] [--force]
```

| Option | What it does |
| --- | --- |
| `--release=` | The number of the release to put back; the one before the live one when left out |
| `--force` | Do not ask for confirmation |

## Environment

### env:pull

Fetch an environment's variables from your own Secret Manager, through Brewless. With `--direct`, straight from your machine with a Scaleway key of your own. See [Environment variables](/running/variables).

```bash
brewless env:pull <environment> [--file=] [--direct]
```

### env:push

Write an environment's variables to your own Secret Manager, through Brewless or, with `--direct`, straight from your machine.

```bash
brewless env:push <environment> [--file=] [--force] [--direct]
```

### provision

Make what a new environment needs in your own cloud accounts. See [Setting an environment up](/applications/applications-and-environments#setting-an-environment-up).

```bash
brewless provision <environment> [--database=] [--database-resource=] [--queue=] [--bucket] [--no-database]
```

Without options, in a terminal, it asks what `init` asks for one environment. With an option, or run by a script, it asks nothing: what is left out is a new database, its jobs in that database and no bucket.

| Option | What it does |
| --- | --- |
| `--database=` | `new` for a Serverless SQL Database, `existing` for one in your project, `none` |
| `--database-resource=` | The name of the existing database to use |
| `--queue=` | `database`, `sqs` for a queue at Scaleway Queues, or `none` |
| `--bucket` | Make a private bucket for the files of the application |
| `--no-database` | The same as `--database=none` |

### domain:add

Make an environment answer on a domain of your own, with a certificate. It says when it took over the domain's DNS zone, and when your application still calls the provider's address its own it offers to set `APP_URL` to the domain; only after a yes, for the next deploy. See [Domains](/running/domains) and [Moving your domain to Brewless](/getting-started/moving-your-domain).

```bash
brewless domain:add <environment> <hostname>
```

### dns:list, dns:add, dns:update, dns:remove

Read and change the records of a DNS zone Brewless manages, at Bunny DNS or Scaleway DNS. `dns:list` without a zone lists the zones with the provider each lives at; with one it lists the records and their ids (a number at Bunny DNS, a UUID at Scaleway DNS). `dns:remove` asks first; with `--no-interaction` it fails unless you pass `--force`. See [DNS records](/running/dns-records).

```bash
brewless dns:list [<zone>]
brewless dns:add <zone> <type> <name> <value> [--ttl=] [--priority=] [--weight=] [--port=] [--flags=] [--tag=]
brewless dns:update <zone> <id> [--type=] [--name=] [--value=] [--ttl=] [--priority=] [--weight=] [--port=] [--flags=] [--tag=]
brewless dns:remove <zone> <id> [--force]
```

### scale

Set between how many replicas your provider scales an environment. See [Scaling](/running/scaling).

```bash
brewless scale <environment> [--min=] [--max=]
```

### command

Run one console command in an environment and show what it prints. See [Commands](/running/commands).

```bash
brewless command <environment> <line> [--force]
```

### logs

Show the logs of an environment, read live from your provider. See [Logs](/running/logs).

```bash
brewless logs <environment> [--tail] [--range=] [--search=] [--source=]
```

## Leaving

### export

Write everything Brewless knows about an environment to a folder, with Terraform and without the value of any secret. See [Leaving Brewless](/applications/leaving).

```bash
brewless export <environment> [--output=]
```

| Option | What it does |
| --- | --- |
| `--output=` | The folder to write to. Default: `brewless-export-<application>-<environment>` |

### detach

Stop Brewless managing an environment. Everything keeps running in your own accounts. See [Leaving Brewless](/applications/leaving).

```bash
brewless detach <environment> [--output=] [--force]
```

| Option | What it does |
| --- | --- |
| `--output=` | The folder for the last export |
| `--force` | Do not ask for confirmation |
