Skip to content

feat!: Adopt subcommand CLI with suppressions and explain mode#16

Merged
danthompson merged 3 commits into
mainfrom
feat/cli-subcommands-and-suppressions
May 11, 2026
Merged

feat!: Adopt subcommand CLI with suppressions and explain mode#16
danthompson merged 3 commits into
mainfrom
feat/cli-subcommands-and-suppressions

Conversation

@danthompson
Copy link
Copy Markdown
Member

  • Split the CLI into check, rule, and suppress subcommands. Add --config, --isolated, and pyproject.toml-style config sources.
  • Replace the "baseline" vocabulary with "suppressions" across config keys, generated files, and docs. The mechanism suppresses violations; the new name describes that directly.
  • Add a structured explain mode: rule <id> renders description, rationale, remediation, exceptions, and examples; --output-format json dumps the rule metadata.

Breaking changes: top-level options moved under check; baseline.yml and related keys renamed to suppressions.

"Baseline" implied an accepted state; "suppressions" describes what
the file actually is: a list of violations being suppressed.

Internal renames:

- baseline.py -> suppressions.py
- generate_baseline / merge_baseline / load_baseline /
  _resolve_baseline / _emit_baseline -> *_suppressions
- BASELINE_FILENAME -> SUPPRESSIONS_FILENAME
- run() parameter baseline_path -> suppressions_path

User-facing renames:

- --baseline PATH -> --suppressions PATH
- --generate-baseline -> --write-suppressions
- Default filename dbt-lint-baseline.yml -> .dbt-lint-suppressions.yml

Behavior preserved. --write-suppressions still writes via --output
and returns exit 0; auto-discovery still walks the discovered config
directory.

BREAKING CHANGE: --baseline and --generate-baseline removed; default
suppressions filename changed.
Replace the single top-level command with a click.group exposing two
explicit subcommands: `check` for linting and `rule` for listing
rules. Bare `dbt-lint`, no-arg `check`, and no-arg `rule` print help.
`rule` requires either a rule ID or `--all`.

Add walk-up config discovery from cwd. Resolution order is explicit
`--config`, then `pyproject.toml [tool.dbt_lint]`, then `dbt-lint.yml`,
then defaults; first match wins. The TOML section uses underscores to
match the package name; the YAML file uses hyphens to match the CLI
binary.

Add `--isolated` to bypass config discovery and suppressions auto-load
in favor of defaults. Add `--exit-zero` to `check` for forcing exit
code 0 regardless of violations. Rename `--format` to `--output-format`
across subcommands. Remove `--list-rules`, `--generate-baseline`, top-
level `--output`, and `--baseline PATH`. `check --write-suppressions`
now writes the YAML to stdout (redirect with `>`) and skips
suppressions auto-load during the producing run so the regenerated
file captures the full current violation set.

Rename the config-file convention from `dbt_lint.yml` to `dbt-lint.yml`
for hyphen consistency with the CLI binary.

BREAKING CHANGE: CLI surface reshaped. Migration:
- `dbt-lint manifest.json` -> `dbt-lint check manifest.json`
- `dbt-lint --list-rules` -> `dbt-lint rule --all`
- `--generate-baseline ... --output PATH` -> `check --write-suppressions > PATH`
- `--baseline PATH` -> `--suppressions PATH`
- `--format` -> `--output-format`
- `dbt_lint.yml` -> `dbt-lint.yml` (or migrate to `[tool.dbt_lint]` in `pyproject.toml`)
Render description, rationale, remediation, exceptions, and examples
for a single rule. Empty sections are omitted; --output-format json
dumps the RuleInfo dataclass.

Wire --config and --isolated into the rule subcommand so custom rules
declared in config appear in `rule --all` and `rule <id>`.

Promote _assemble_rules to public collect_rules and add UnknownRuleError
so the rule subcommand has one LintError surface to catch.

Restrict `rule --output-format` to text|json; concise and grouped are
violation layouts with no meaning for rule metadata.
@danthompson danthompson merged commit 498a63d into main May 11, 2026
5 checks passed
@danthompson danthompson deleted the feat/cli-subcommands-and-suppressions branch May 11, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant