# Diagrid CLI for Dapr Ops Dashboard

The Diagrid CLI allows you to run commands against the Dapr Ops Dashboard APIs and can be used to perform all the actions available in the Dapr Ops Dashboard console. This includes:

- Create and manage cluster connections
- Install and upgrade Dapr
- Manage users
- Run diagnostics

## Installing the CLI

Download and install the Diagrid CLI using the following command:

**MacOS**

```bash
curl -o- https://downloads.diagrid.io/cli/install.sh | bash
```

Move the `diagrid` binary into your path so you can run it from anywhere. For example:

```bash
sudo mv ./diagrid /usr/local/bin
```

**Linux**

```bash
curl -o- https://downloads.diagrid.io/cli/install.sh | bash
```

Move the `diagrid` binary into your path so you can run it from anywhere. For example:

```bash
sudo mv ./diagrid /usr/local/bin
```

**Windows**

Download the PowerShell installer

```shell
iwr -Uri https://downloads.diagrid.io/cli/install.ps1 -OutFile install.ps1
```

Execute the PowerShell installer

```
.\install.ps1
```

:::tip
You may need to temporarily set the PowerShell execution policy to `Unrestricted` to allow the installer to execute.

```shell
Set-ExecutionPolicy Unrestricted -Scope CurrentUser

.\install.ps1

Set-ExecutionPolicy Restricted -Scope CurrentUser
```

:::

Move the `diagrid.exe` executable into your path so you can run it from anywhere. For example:

```shell
Move-Item .\diagrid.exe "$($env:USERPROFILE)\bin"
```

:::warning

Support for the Diagrid CLI on Windows is experimental and we recommend installing it via [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) if available. The CLI on WSL2 requires https://wslutiliti.es/wslu/ to support deeper OS integration.

:::

## Using the CLI

The CLI is a static binary that should be executed from the command line. Help pages are available to allow you to discover how to navigate the command tree and to see what flags are available on each command.

In order for the CLI to authenticate to the Diagrid Cloud API it is important that you first login using:

```
diagrid login
```

The Diagrid CLI is compatible with both products: Catalyst and Dapr Ops Dashboard. If you have access to both products, you can choose which set of commands to use by specifying the product name with the command:

```
diagrid product use conductor
```

Logging in will store the credentials in the `~/.diagrid` directory on your filesystem. If you want to clean up your user data you can logout with the command:

```
diagrid logout
```

To verify the identity and current organization of your user you can use this command:

```
diagrid whoami
```

Once logged in, you may exercise the other commands the CLI supports, such as:

```
diagrid clusters list
```

## Gathering diagnostics

To capture detailed Diagrid Agent diagnostic information, logs, Kubernetes configurations, perform the following steps:

- Set kubectl context for the correct Kubernetes cluster
- Run the following command: `diagrid diagnose`
- Send the above file to support@diagrid.io

## Connecting a cluster

To connect your Kubernetes cluster to Dapr Ops Dashboard you can perform the following steps:

- Set kubectl context for the correct Kubernetes cluster
- Use the command `diagrid clusters connect`

**Example:**

```
diagrid clusters connect --name mycluster --install-dapr --profile dev --manifests | kubectl apply -f -
```
