# CLI

![](https://1676458320-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LsNFVozLgvw3NDMzxBg%2F-LyjOXNgBfmypufNTgz2%2F-LyjS2BGab5vbhGqXV03%2FTerminal0001.png?alt=media\&token=df122083-1b9f-4af8-8c0a-da04d043d412)

The following commands let you manipulate objects in the Grey Matter mesh.

| Command                   | Description                                                                                                                                                     |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `greymatter`              | [Base command](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/greymatter) for performing operations on the Grey Matter Service Mesh. |
| `configs`                 | Display the current CLI configurations.                                                                                                                         |
| `create`                  | [Create](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/create) a specific object in the Grey Matter mesh.                           |
| `delete`                  | [Delete](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/delete) a specific object and its configurations from the Grey Matter mesh.  |
| `edit`                    | [Edit](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/edit) the configuration of an existing object in the Grey Matter mesh.         |
| `generate`                | [Generate](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/generate) textual output from a template.                                  |
| `get`                     | [Get](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/get) a specific object and its configurations from the Grey Matter mesh.        |
| `help`                    | Display help text for commands                                                                                                                                  |
| `list`                    | [List](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/list) objects and their configurations in the Grey Matter mesh.                |
| `import-zone/export-zone` | [import/export](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/export-zone-and-import-zone) zones and all their associated objects.  |
| `sync`                    | [Synchronizes](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/sync) the source and destination.                                      |
| `utils`                   | [Utils](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/utils) contain utility sub-commands.                                          |
| `version`                 | Display the version and build information of the CLI                                                                                                            |

## Configuring CLI

The Grey Matter CLI global options are configured either through command-line flags, a configuration file, or their environment variable equivalents, listed below.

The order of precedence for all settings is flags > environment variables > a configuration file. For more information about configuration files, see [Configuration File](#configuration-file) section below.

### General Settings

| Flag                    | Environment Variable           | Description                                                                                                            | Required | Default                  | Example      |
| ----------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------ | ------------ |
| `-c`, `--config`        | (not configurable via env var) | Location of the CLI config file                                                                                        | No       | "$HOME/.greymatter.yaml" | \~/prod.json |
| `-l`, `--console.level` | `GREYMATTER_CONSOLE_LEVEL`     | Log level setting of the `greymatter` CLI. Valid values are "debug", "info", "error", or "none"                        | No       | error                    | info         |
| `-f`, `--format`        | `GREYMATTER_FORMAT`            | Whether to use JSON or YAML to format objects sent or received from the Control API. Valid values are "json" or "yaml" | No       | ""                       | yaml         |

### Control API Settings

| Flag             | Environment Variable      | Description                                                                                                                                             | Required | Default | Example                                     |
| ---------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- | ------------------------------------------- |
| `--api.host`     | `GREYMATTER_API_HOST`     | The host and port of the Grey Matter installation, without protocol prefix                                                                              | Yes      | ""      | greymatter.development.deciphernow\.com:443 |
| `--api.prefix`   | `GREYMATTER_API_PREFIX`   | The route to the Control API within a Grey Matter installation without trailing slash                                                                   | Yes      | ""      | /services/gm-control-api/1.0                |
| `--api.version`  | `GREYMATTER_API_VERSION`  | The schema version of the Control API                                                                                                                   | No       | "v1.0"  | v1.0                                        |
| `--api.ssl`      | `GREYMATTER_API_SSL`      | Whether to use SSL (https) when communicating with the Control API service                                                                              | No       | ""      | true                                        |
| `--api.sslcert`  | `GREYMATTER_API_SSLCERT`  | Path to a PEM-encoded user PKI certificate file authorized to configure the mesh                                                                        | No       | ""      | /path/to/cert.pem                           |
| `--api.sslkey`   | `GREYMATTER_API_SSLKEY`   | Path to a PEM-encoded user PKI key file authorized to configure the mesh (un-encrypted)                                                                 | No       | ""      | /path/to/key.pem                            |
| `--api.insecure` | `GREYMATTER_API_INSECURE` | Whether to attempt verification of the host's certificate                                                                                               | No       | false   | true                                        |
| `--api.header`   | `GREYMATTER_API_HEADER`   | Specifies a custom header to send with every API request. Headers are given as name:value pairs, and can be separated with commas for multiple headers. | No       | ""      | "Authorization: Bearer y29..."              |

### Catalog API Settings

| Flag                 | Environment Variable          | Description                                                                                                       | Required | Default                 | Example                                     |
| -------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------- | -------- | ----------------------- | ------------------------------------------- |
| `--catalog.zoneName` | `GREYMATTER_CATALOG_ZONENAME` | The name of the zone used by the Grey Matter Control server and its discovered sidecars                           | Yes      | ""                      | zone-default-zone                           |
| `--catalog.host`     | `GREYMATTER_CATALOG_HOST`     | The host and port of the Grey Matter Catalog installation (if different from `api.host`), without protocol prefix | No       | Value of `api.host`     | greymatter.development.deciphernow\.com:443 |
| `--catalog.prefix`   | `GREYMATTER_CATALOG_PREFIX`   | The route to the Catalog API within a Grey Matter installation without trailing slash                             | Yes      | ""                      | /services/gm-catalog/1.0                    |
| `--catalog.ssl`      | `GREYMATTER_CATALOG_SSL`      | Whether to use SSL (https) when communicating with the Catalog API                                                | No       | Value of `api.ssl`      | true                                        |
| `--catalog.sslcert`  | `GREYMATTER_CATALOG_SSLCERT`  | Path to a PEM-encoded user PKI certificate file authorized to configure the mesh                                  | No       | Value of `api.sslcert`  | /path/to/cert.pem                           |
| `--catalog.sslkey`   | `GREYMATTER_CATALOG_SSLKEY`   | Path to a PEM-encoded user PKI key file authorized to configure the mesh (un-encrypted)                           | No       | Value of `api.sslkey`   | /path/to/key.pem                            |
| `--catalog.insecure` | `GREYMATTER_CATALOG_INSECURE` | Whether to attempt verification of the host's certificate                                                         | No       | Value of `api.insecure` | true                                        |

### Configuration File

Unless specified via `--config` flag, Grey Matter CLI will search a user's home directory for a file with a name prefixed with `.greymatter`. The accepted format of the file are JSON and YAML.

{% hint style="warning" %}
If multiple files are found, the CLI will nondeterministically choose one of them. Therefore it's best to have only one file.
{% endhint %}

As mentioned above, the order of precedence for all settings is flags > environment variables > a configuration file. So if there are flags or environment variables set, what is in the configuration file will not affect the behavior of the CLI. For checking the actual configuration read by the CLI, please type `greymatter configs` to check. If you are using a custom configuration file, please run the command like so `greymatter configs --config [your-config-file-name]`.

The following configuration is a minimal example that is typical for normal use of the CLI:

`greymatter.yaml` or `.greymatter.yml`

```yaml
console:
  level: error

format: yaml

api:
  host: localhost:30000
  prefix: /services/control-api/latest
  ssl: true
  insecure: true
  sslcert: /Users/my-name/git/helm-charts/certs/quickstart.crt
  sslkey:  /Users/my-name/git/helm-charts/certs/quickstart.key

catalog:
  prefix: "/services/catalog/latest"
  zoneName: zone-default-zone
```

`greymatter.json`

```javascript
{
  "console": {
    "level": "error"
  },
  "format": "yaml",
  "api": {
    "host": "localhost:30000",
    "prefix": "/services/control-api/latest",
    "ssl": true,
    "insecure": true,
    "sslcert": "/Users/someone/git/helm-charts/certs/quickstart.crt",
    "sslkey": "/Users/someone/git/helm-charts/certs/quickstart.key"
  },
  "catalog": {
    "prefix": "/services/catalog/latest",
    "zoneName": "zone-default-zone"
  }
}
```

{% hint style="success" %}
When configuring the CLI's connection to the Catalog API, you may omit most of its connection settings if they coincide with the corresponding Control API settings.

For configuring `sync` functionality, it is recommended to do so via a config file. For more details. please refer to the [sync](https://greymatter.gitbook.io/grey-matter-documentation/1.3/reference/cli/sync) section.
{% endhint %}

## Questions

{% hint style="success" %}
**Need help with the CLI?** Contact our team at [Grey Matter Support](https://support.greymatter.io/support/home).
{% endhint %}
