# Install the CLI

> Install the lumen command line, sign in, pick a workspace and run your first commands, in a terminal or in CI.

Source: https://docs.go-lumen.ai/he/api/install-the-cli

The `lumen` command line manages your workspace from a terminal or a CI job: list and apply flows, start a run on files and follow it, and add connections. It has no setup step. The first command that needs you signs you in.

-   5 minutes
-   macOS, Linux, Windows

## Install it

`lumen` is one binary with no dependencies. Pick one way to get it.

**Homebrew:**

```bash
brew install --cask buji-code/tap/lumen
```

The cask installs the binary and the shell completions for bash, zsh and fish.

**Release archive:**

Download the archive for your system, check it against `checksums.txt`, unpack it and put `lumen` on your `PATH`.

| System | Archive |
| --- | --- |
| macOS, Linux | `lumen_<version>_<os>_<arch>.tar.gz` (`darwin` or `linux`, `amd64` or `arm64`) |
| Windows | `lumen_<version>_windows_<arch>.zip` |

Each archive also holds a README and the completion scripts.

**From source:**

From a checkout of the Lumen repository, with Go installed:

```bash
make cli
./bin/lumen version
```

> **Release publishing:**
> 
> The release configuration for the archives and the Homebrew cask is in the repository, but the job that publishes them is not switched on yet. Until the first CLI release is published, build from source.

Check that it runs:

```bash
lumen version
```

Turn on tab completion for your shell with `lumen completion bash`, `lumen completion zsh`, `lumen completion fish` or `lumen completion powershell`. Completion offers resource types, the names of your flows and connections, fields and enum values.

## Sign in

Run any command that talks to your workspace:

```bash
lumen get flows
```

The first time, `lumen` prints `Opening your browser to sign in...`, you sign in as you do in the console, and the command runs again. The token is saved and renewed quietly, so the browser comes back only when your sign-in is revoked or has lapsed.

You can also sign in on purpose, or sign out:

```bash
lumen login
lumen logout
```

| Situation | What happens |
| --- | --- |
| A terminal with a browser | The browser opens. `lumen` listens on `127.0.0.1` (the first free port of 8765, 8766 and 8767) to receive the answer. |
| Over SSH, or no display | `lumen` prints a link and a code instead. Open the link on any device and confirm the code. |
| You belong to several organizations | The sign-in page asks which one. Pass `--org NAME` to skip the question. |
| CI, a pipe, or no terminal | A browser is never opened. The command stops and tells you to run `lumen login` or set `LUMEN_TOKEN`. |

### Sign in without a person

A script or a CI job signs in with a workspace API key. Create one in the console (see [API keys](https://docs.go-lumen.ai/he/api/api-keys.md)), then give it to `lumen` as the token:

```bash
export LUMEN_TOKEN=lmn_eu_...   # from your CI's secret store
lumen apply -f flows/
```

`--token` does the same for one command. A key belongs to one workspace, so `lumen` asks the server which one and you do not pass `-w`. To keep a key in a named context instead, use `lumen login --context ci --static-token "$TOKEN"`.

## Choose a workspace

After you sign in, `lumen` asks the server which workspace your login belongs to and remembers it. Most people never set one. To act in a workspace by name, for one command:

```bash
lumen get flows -w acme
```

`-w` accepts only a workspace your login can use.

A context is a saved server, workspace and sign-in. You have one per Lumen installation you use:

```bash
lumen context list
lumen context current
lumen context use NAME
lumen context set NAME --server https://api.go-lumen.ai -w acme
lumen context delete NAME
```

`--context NAME` picks a context for one command, and `--server` (or `LUMEN_SERVER`) overrides its server.

## Where it keeps things

| What | Where |
| --- | --- |
| Contexts | `~/.config/lumen/config.yaml`, or the path in `LUMEN_CONFIG`, or `--config`. `XDG_CONFIG_HOME` moves the folder. |
| Tokens | `~/.config/lumen/tokens/NAME.json`, readable by you only. |
| Discovery cache | `~/Library/Caches/lumen` on macOS, `~/.cache/lumen` on Linux, or `LUMEN_CACHE_DIR`. Kept for six hours. |

The cache holds the list of resource types and their fields. `lumen` builds its commands from what the server offers, so a new kind of resource or a new field shows up without a new CLI version. Use `--refresh` to read it again now.

## Your first commands

```bash
lumen api-resources              # the resource types your workspace offers
lumen get flows                  # a table of your flows
lumen get runs --phase Failed    # filter flags come from the fields of a run
lumen describe flow NAME         # everything about one flow
lumen explain flow.spec.nodes    # what a field means
lumen run NAME -f march.pdf --wait
```

| Command | What it does |
| --- | --- |
| `get RESOURCE [NAME...]` | Lists or shows resources. `-o yaml`, `-o json`, `-o name` and `-o wide` change the output. |
| `describe RESOURCE NAME` | Shows one resource, its status and problems included. |
| `apply -f FILE` | Creates or updates resources from files. See [Flows as YAML](https://docs.go-lumen.ai/he/api/flows-as-yaml.md). |
| `delete RESOURCE NAME` | Deletes a resource. |
| `run FLOW [-f FILE...] [--wait]` | Starts the flow's manual trigger, as the console's **Run** button does. `-f` sends files (up to 23 MiB in all). `--wait` prints each step as it finishes and exits 1 if the run fails. |
| `cancel run RUN` | Stops a run that has not ended. `--reason` says why on the run. |
| `eval flow FLOW` | Runs a flow's test cases and scores them. |
| `connect CLASS [NAME]` | Adds a connection, asking for what it needs. Secrets are read with no echo, never from a flag. |
| `explain RESOURCE.FIELD` | Describes a field from the published schema. |

`lumen COMMAND --help` lists the flags of any command.

> **Errors in plain words:**
> 
> `lumen` says "No flow named invoices in workspace acme." instead of printing a raw API error. Add `--verbose` to see the server's own text under it.

## Next steps

[Flows as YAMLKeep flows in a repository and apply them from CI.](https://docs.go-lumen.ai/he/api/flows-as-yaml.md)[API keysCreate the key a script or CI job signs in with.](https://docs.go-lumen.ai/he/api/api-keys.md)[Runtime APIStart runs and read results over HTTP.](https://docs.go-lumen.ai/he/api/runtime-api.md)
