dbt-labs / dbt-labs/dbt

[CT-2767] [Feature] Use `--quiet` by default for `dbt list --output json`

Open
#7,994 3 comments 0 reactions 1 assignee Claimed by @jtcohen6 View on GitHub
cli engine:v1 Refinement type:feature
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

### Is this your first time submitting a feature request?

- [X] I have read the [expectations for open source contributors](https://docs.getdbt.com/docs/contributing/oss-expectations)
- [X] I have searched the existing issues, and I could not find an existing issue for this feature
- [X] I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

### Describe the feature

It is often useful to pipe or redirect JSON output of `dbt list` for further downstream processing with a tool like the Python built-in `json.tool` or the [`jq`](https://jqlang.github.io/jq/) swiss army knife.

It would be nice if the syntax were as simple as this to pretty-print the JSON output:
```shell
dbt list --output json | python -m json.tool --json-lines
```

or this to extract the `name` keys:

```shell
dbt list --output json | jq ".name"
```

But currently, the non-error log output needs to be [suppressed](https://docs.getdbt.com/reference/global-configs/logs#suppress-non-error-logs-in-output) like this:
```shell
dbt --quiet list --output json | python -m json.tool --json-lines
dbt -q list --output json | jq ".name"
```

See https://github.com/dbt-labs/dbt-core/issues/7987 for an example.

### Relevant background

The guide for upgrading to v1.5 says the following:

> The `dbt list` command will now include `INFO` level logs by default. Previously, the `list` command (and _only_ the `list` command) had `WARN`-level stdout logging, to support piping its results to [`jq`](https://stedolan.github.io/jq/manual/), a file, or another process. To achieve that goal, you can use either of the following parameters:
> - `dbt --log-level warn list` (recommended; equivalent to previous default)
> - `dbt --quiet list` (suppresses all logging less than ERROR level, except for "printed" messages and `list` output)

### Describe alternatives you've considered

It's certainly possible to continue to require usage of the `QUIET` config, it's just harder for folks to discover.

The problem is that the default option gives output that is un-parsable by any downstream tooling 😢

### Who will this benefit?

Anyone that want to do any JSON post-processing in a terminal.

### Are you interested in contributing this feature?

_No response_

### Anything else?

If we were to adopt this enhancement request, would we also need/want to add a `--no-quiet` option to remove the suppression of non-error output? I can't think of a particular use-case off-hand, but it wouldn't surprise me if one exists.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.