Skip to content

Commit

Permalink
adding dbt env command (#4792)
Browse files Browse the repository at this point in the history
this pr adds the dbt environment command and its flags to the docs site
for the cloud cli. it also sets it up so that may add more
flags/commands if necessary.

it has been added in the following pages:
- https://docs.getdbt.com/reference/dbt-commands -- added to the table
list
- https://docs.getdbt.com/reference/commands/dbt-environment -- created
a brand new page
- https://docs.getdbt.com/docs/cloud/cloud-cli-installation -- in the
installation steps
- https://docs.getdbt.com/docs/cloud/configure-cloud-cli -- in the
config steps

PR also renames the sidebar so the cloud cli is less repeated. add;l
details [provided
here](https://www.notion.so/dbtlabs/dbt-env-show-details-82c33bf72bb34142ac7511ecebcf1b66)
on the command and the next steps.
  • Loading branch information
mirnawong1 authored Jan 29, 2024
2 parents 8092aeb + 61fedc1 commit 0f982ff
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 10 deletions.
10 changes: 5 additions & 5 deletions website/docs/docs/cloud/cloud-cli-installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Install dbt Cloud CLI
sidebar_label: "Install dbt Cloud CLI"
sidebar_label: "Installation"
id: cloud-cli-installation
description: "Instructions for installing and configuring dbt Cloud CLI"
pagination_next: "docs/cloud/configure-cloud-cli"
Expand Down Expand Up @@ -75,7 +75,7 @@ Before you begin, make sure you have [Homebrew installed](http://brew.sh/) in yo
4. Clone your repository to your local computer using `git clone`. For example, to clone a GitHub repo using HTTPS format, run `git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY`.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like [`dbt environment show`](/reference/commands/dbt-environment) to view your dbt Cloud configuration or `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
</TabItem>
Expand Down Expand Up @@ -106,7 +106,7 @@ Note that if you are using VS Code, you must restart it to pick up modified envi
4. Clone your repository to your local computer using `git clone`. For example, to clone a GitHub repo using HTTPS format, run `git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY`.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like [`dbt environment show`](/reference/commands/dbt-environment) to view your dbt Cloud configuration or `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
</TabItem>
Expand Down Expand Up @@ -140,7 +140,7 @@ Advanced users can configure multiple projects to use the same Cloud CLI executa
4. Clone your repository to your local computer using `git clone`. For example, to clone a GitHub repo using HTTPS format, run `git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY`.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like [`dbt environment show`](/reference/commands/dbt-environment) to view your dbt Cloud configuration or `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
</TabItem>
Expand Down Expand Up @@ -205,7 +205,7 @@ We recommend using virtual environments (venv) to namespace `cloud-cli`.
4. Clone your repository to your local computer using `git clone`. For example, to clone a GitHub repo using HTTPS format, run `git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY`.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
5. After cloning your repo, [configure](/docs/cloud/configure-cloud-cli) the dbt Cloud CLI for your dbt Cloud project. This lets you run dbt commands like [`dbt environment show`](/reference/commands/dbt-environment) to view your dbt Cloud configuration or `dbt compile` to compile your project and validate models and tests. You can also add, edit, and synchronize files with your repo.
</TabItem>
Expand Down
10 changes: 6 additions & 4 deletions website/docs/docs/cloud/configure-cloud-cli.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Configure dbt Cloud CLI
title: Configure and use the dbt Cloud CLI
id: configure-cloud-cli
description: "Instructions on how to configure the dbt Cloud CLI"
sidebar_label: "Configure dbt Cloud CLI"
sidebar_label: "Configuration and usage"
pagination_next: null
---

Expand Down Expand Up @@ -75,7 +75,9 @@ Once you install the dbt Cloud CLI, you need to configure it to connect to a dbt

- To find your project ID, select **Develop** in the dbt Cloud navigation menu. You can use the URL to find the project ID. For example, in `https://cloud.getdbt.com/develop/26228/projects/123456`, the project ID is `123456`.

6. You can now [use the dbt Cloud CLI](#use-the-dbt-cloud-cli) and run [dbt commands](/reference/dbt-commands) like `dbt compile`. With your repo recloned, you can add, edit, and sync files with your repo.
6. You should now be able to [use the dbt Cloud CLI](#use-the-dbt-cloud-cli) and run [dbt commands](/reference/dbt-commands) like [`dbt environment show`](/reference/commands/dbt-environment) to view your dbt Cloud configuration details or `dbt compile` to compile models in your dbt project.

With your repo recloned, you can add, edit, and sync files with your repo.

### Set environment variables

Expand All @@ -89,7 +91,7 @@ To set environment variables in the dbt Cloud CLI for your dbt project:

## Use the dbt Cloud CLI

- The dbt Cloud CLI uses the same set of [dbt commands](/reference/dbt-commands) and [MetricFlow commands](/docs/build/metricflow-commands) as dbt Core to execute the commands you provide.
- The dbt Cloud CLI uses the same set of [dbt commands](/reference/dbt-commands) and [MetricFlow commands](/docs/build/metricflow-commands) as dbt Core to execute the commands you provide. For example, use the [`dbt environment`](/reference/commands/dbt-environment) command to view your dbt Cloud configuration details.
- It allows you to automatically defer build artifacts to your Cloud project's production environment.
- It also supports [project dependencies](/docs/collaborate/govern/project-dependencies), which allows you to depend on another project using the metadata service in dbt Cloud.
- Project dependencies instantly connect to and reference (or `ref`) public models defined in other projects. You don't need to execute or analyze these upstream models yourself. Instead, you treat them as an API that returns a dataset.
Expand Down
98 changes: 98 additions & 0 deletions website/docs/reference/commands/dbt-environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: "About dbt environment command"
sidebar_label: "environment"
id: dbt-environment
---

The `dbt environment` command enables you to interact with your dbt Cloud environment. Use the command for:

- Viewing your local configuration details (account ID, active project ID, deployment environment, and more).
- Viewing your dbt Cloud configuration details (environment ID, environment name, connection type, and more).

This guide lists all the commands and options you can use with `dbt environment` in the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation). To use them, add a command or option like this: `dbt environment [command]` or use the shorthand `dbt env [command]`.

### dbt environment show

`show` command &mdash; To view your local and dbt Cloud configuration details. To run the command with the dbt Cloud CLI, type one of the following commands, including the shorthand:

```shell
dbt environment show
```
```shell
dbt env show
```

The command returns the following information:

```bash
❯ dbt env show
Local Configuration:
Active account ID 185854
Active project ID 271692
Active host name cloud.getdbt.com
dbt_cloud.yml file path /Users/cesar/.dbt/dbt_cloud.yml
dbt_project.yml file path /Users/cesar/git/cloud-cli-test-project/dbt_project.yml
dbt Cloud CLI version 0.35.7
OS info darwin arm64

Cloud Configuration:
Account ID 185854
Project ID 271692
Project name Snowflake
Environment ID 243762
Environment name Development
Defer environment ID [N/A]
dbt version 1.6.0-latest
Target name default
Connection type snowflake

Snowflake Connection Details:
Account ska67070
Warehouse DBT_TESTING_ALT
Database DBT_TEST
Schema CLOUD_CLI_TESTING
Role SYSADMIN
User dbt_cloud_user
Client session keep alive false
```

Note, that dbt Cloud won't return anything that is a secret key and will return an 'NA' for any field that isn't configured.

### dbt environment flags

Use the following flags (or options) with the `dbt environment` command:

- `-h`, `--help` &mdash; To view the help documentation for a specific command in your command line interface.

```shell
dbt environment [command] --help
dbt environment [command] -h
```

The `--help` flag returns the following information:

```bash
❯ dbt help environment
Interact with dbt environments

Usage:
dbt environment [command]

Aliases:
environment, env

Available Commands:
show Show the working environment

Flags:
-h, --help help for environment

Use "dbt environment [command] --help" for more information about a command.
```

For example, to view the help documentation for the `show` command, type one of the following commands, including the shorthand:

```shell
dbt environment show --help
dbt env show -h
```
3 changes: 2 additions & 1 deletion website/docs/reference/dbt-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ All commands in the table are compatible with either the dbt Cloud IDE, dbt Clou

You can run dbt commands in your specific tool by prefixing them with `dbt`. For example, to run the `test` command, type `dbt test`.

| Command | Description | Compatible tools | Version |
| Command | Description | Compatible tools | <div style={{width:'220px'}}>Version</div> |
| ------- | ----------- | ---------------- | ------- |
| [build](/reference/commands/build) | Build and test all selected resources (models, seeds, snapshots, tests) | All | All [supported versions](/docs/dbt-versions/core) |
| cancel | Cancels the most recent invocation.| dbt Cloud CLI | Requires [dbt v1.6 or higher](/docs/dbt-versions/core) |
Expand All @@ -27,6 +27,7 @@ You can run dbt commands in your specific tool by prefixing them with `dbt`. Fo
| [debug](/reference/commands/debug) | Debugs dbt connections and projects | dbt Cloud IDE <br /> dbt Core | All [supported versions](/docs/dbt-versions/core) |
| [deps](/reference/commands/deps) | Downloads dependencies for a project | All | All [supported versions](/docs/dbt-versions/core) |
| [docs](/reference/commands/cmd-docs) | Generates documentation for a project | All | All [supported versions](/docs/dbt-versions/core) |
| [environment](/reference/commands/dbt-environment) | Enables you to interact with your dbt Cloud environment. | dbt Cloud CLI | Requires [dbt v1.5 or higher](/docs/dbt-versions/core) |
| help | Displays help information for any command | dbt Core <br /> dbt Cloud CLI | All [supported versions](/docs/dbt-versions/core) |
| [init](/reference/commands/init) | Initializes a new dbt project | dbt Core | All [supported versions](/docs/dbt-versions/core) |
| [list](/reference/commands/list) | Lists resources defined in a dbt project | All | All [supported versions](/docs/dbt-versions/core) |
Expand Down
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ const sidebarSettings = {
"reference/commands/compile",
"reference/commands/debug",
"reference/commands/deps",
"reference/commands/dbt-environment",
"reference/commands/init",
"reference/commands/list",
"reference/commands/parse",
Expand Down

0 comments on commit 0f982ff

Please sign in to comment.