Skip to content

Commit

Permalink
s/OptionEatAll/MultiOption
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Jan 19, 2023
1 parent e682628 commit 6516e5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions core/dbt/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@


# Implementation from: https://stackoverflow.com/a/48394004
# Note OptionEatAll options must be specified with type=tuple (https://github.com/pallets/click/issues/2012)
class OptionEatAll(click.Option):
# Note MultiOption options must be specified with type=tuple or type=ChoiceTuple (https://github.com/pallets/click/issues/2012)
class MultiOption(click.Option):
def __init__(self, *args, **kwargs):
self.save_other_options = kwargs.pop("save_other_options", True)
nargs = kwargs.pop("nargs", -1)
assert nargs == -1, "nargs, if set, must be -1 not {}".format(nargs)
super(OptionEatAll, self).__init__(*args, **kwargs)
super(MultiOption, self).__init__(*args, **kwargs)
self._previous_parser_process = None
self._eat_all_parser = None

Expand All @@ -33,7 +33,7 @@ def parser_process(value, state):
# call the actual process
self._previous_parser_process(value, state)

retval = super(OptionEatAll, self).add_to_parser(parser, ctx)
retval = super(MultiOption, self).add_to_parser(parser, ctx)
for name in self.opts:
our_parser = parser._long_opt.get(name) or parser._short_opt.get(name)
if our_parser:
Expand Down
10 changes: 5 additions & 5 deletions core/dbt/cli/params.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path, PurePath

import click
from dbt.cli.options import OptionEatAll
from dbt.cli.options import MultiOption
from dbt.cli.option_types import YAML, ChoiceTuple
from dbt.cli.resolvers import default_project_dir, default_profiles_dir

Expand Down Expand Up @@ -82,7 +82,7 @@
)

exclude = click.option(
"--exclude", envvar=None, type=tuple, cls=OptionEatAll, help="Specify the nodes to exclude."
"--exclude", envvar=None, type=tuple, cls=MultiOption, help="Specify the nodes to exclude."
)

fail_fast = click.option(
Expand Down Expand Up @@ -142,7 +142,7 @@
"-m",
envvar=None,
help="Specify the nodes to include.",
cls=OptionEatAll,
cls=MultiOption,
type=tuple,
)

Expand Down Expand Up @@ -264,7 +264,7 @@
],
case_sensitive=False,
),
cls=OptionEatAll,
cls=MultiOption,
default=(),
)

Expand All @@ -273,7 +273,7 @@
"--select",
envvar=None,
help="Specify the nodes to include.",
cls=OptionEatAll,
cls=MultiOption,
type=tuple,
)

Expand Down

0 comments on commit 6516e5c

Please sign in to comment.