Skip to content

Commit

Permalink
Second pass at organizing cli param click options
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Jan 23, 2025
1 parent dc34e3b commit b38d55a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions core/dbt/cli/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
from dbt.cli.resolvers import default_profiles_dir, default_project_dir
from dbt.version import get_version_information

# --- shared option specs --- #
model_decls = ("-m", "--models", "--model")
select_decls = ("-s", "--select")
select_attrs = {
"envvar": None,
"help": "Specify the nodes to include.",
"cls": MultiOption,
"multiple": True,
"type": tuple,
}

# --- The actual option definitions --- #
add_package = click.option(
"--add-package",
help="Add a package to current package spec, specify it as package-name@version. Change the source with --source flag.",
Expand Down Expand Up @@ -341,6 +353,8 @@
hidden=True,
)

models = click.option(*model_decls, **select_attrs) # type: ignore[arg-type]

# This less standard usage of --output where output_path below is more standard
output = click.option(
"--output",
Expand Down Expand Up @@ -466,6 +480,8 @@
help="Suppress all non-error logging to stdout. Does not affect {{ print() }} macro calls.",
)

raw_select = click.option(*select_decls, **select_attrs) # type: ignore[arg-type]

record_timing_info = click.option(
"--record-timing-info",
"-r",
Expand Down Expand Up @@ -502,22 +518,10 @@
default=(),
)

model_decls = ("-m", "--models", "--model")
select_decls = ("-s", "--select")
select_attrs = {
"envvar": None,
"help": "Specify the nodes to include.",
"cls": MultiOption,
"multiple": True,
"type": tuple,
}

# `--select` and `--models` are analogous for most commands except `dbt list` for legacy reasons.
# Most CLI arguments should use the combined `select` option that aliases `--models` to `--select`.
# However, if you need to split out these separators (like `dbt ls`), use the `models` and `raw_select` options instead.
# See https://github.com/dbt-labs/dbt-core/pull/6774#issuecomment-1408476095 for more info.
models = click.option(*model_decls, **select_attrs) # type: ignore[arg-type]
raw_select = click.option(*select_decls, **select_attrs) # type: ignore[arg-type]
select = click.option(*select_decls, *model_decls, **select_attrs) # type: ignore[arg-type]

selector = click.option(
Expand Down

0 comments on commit b38d55a

Please sign in to comment.