# CLI

Lenses offers a powerful CLI (command-line tool) built-in Go that utilizes the REST and WebSocket APIs of Lenses to communicate with Apache Kafka. It provides a straightforward way to perform common data engineering and site reliability engineering tasks.

## Quick start <a href="#quickstart" id="quickstart"></a>

To use the CLI you must first configure the workspace:

```bash
lenses-cli configure
```

And fill in the details:

```bash
? Host: https://lenseshost:9991
? Auth token or username:
? Password: ******
? Save workspace name: dataopsDev
```

The configuration will be stored in `~/.lenses/config.yml`

## Controlling the output format <a href="#controlling-the-output-format" id="controlling-the-output-format"></a>

The **—output** flag, controls the format of the output.

The value of output can be Table, YAML or JSON. By default, the results of a command are printed as a table.

Additionally, when using the *–output* flag with JSON, two more optional flags are available: *–pretty* and *–query*. These flags can be passed to all commands that fetch and return JSON-formatted results.

* **—pretty** - Enable the pretty format for JSON output of commands (default false).
* **—query** - A jmespath query expression. This allows for querying the JSON output of commands. For more details view the [JMESPATH](http://jmespath.org/) documentation.

## Usage with a service account <a href="#usage-with-a-service-account" id="usage-with-a-service-account"></a>

To use the CLI with a service account for CI/CD you need to pass these options:

{% code fullWidth="false" %}

```bash
lenses-cli topics \
  --token=<service-account-name>:<service-account-token> \
  --host=<lenses-url-host>

# Real Example
lenses-cli topics \
  --token=ci:58d86476-bcc6-47e2-a57e-0c6bbd9c88b9 \
  --host=http://<your-lenses-url>:9991
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/devx/5.5/user-guide/cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
