# Install the CLI

`cafe` is GitCafe's command-line tool. It signs you in, sets up Git
credentials, and manages repositories, pull requests, stacks, issues and more
from the terminal. Every command is listed in the [CLI reference](https://git.cafe/docs/reference/cli.md).

## Install

`cafe` needs [Bun](https://bun.sh) 1.2 or newer; it does not run under Node.js.

```sh
bun install -g @gitcafe/cli
cafe version
```

To try it without installing, run `bunx @gitcafe/cli --help`. When a newer
release is out, `cafe` prints a one-line notice; upgrade with
`bun install -g @gitcafe/cli@latest`.

## Sign in

```sh
cafe auth login
cafe auth http setup
cafe auth status
```

`cafe auth login` shows a code and opens your browser to
[approve the sign-in](https://git.cafe/docs/account/device-authorization.md). The login lasts 90
days. `cafe auth http setup` lets Git use it for HTTPS remotes.

On a server without a browser, set `CAFE_TOKEN` to a
[personal access token](https://git.cafe/docs/account/personal-access-tokens.md) instead. It
takes precedence over a stored login.

## Pick the repository

Inside a clone, commands use that repository. Elsewhere, pass
`--repo owner/name` or set `CAFE_REPO`.

```sh
cafe issue list --repo acme/project
```

## Script with the CLI

- `--json` prints structured output; progress and errors go to stderr.
- `--no-input` fails instead of prompting; `--yes` confirms destructive actions.
- `cafe api <path>` sends an authenticated request to any
  [REST API](https://git.cafe/docs/reference/api.md) endpoint.
- `cafe completion zsh` (or `bash`, `fish`, `powershell`) prints a shell
  completion script.

## Use another GitCafe server

The CLI talks to `https://git.cafe/api` by default. For another server, set
`CAFE_HOST` to its API address or pass `--host` with every command. Logins are
stored per server.
