-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
click working with list #6641
Merged
Merged
click working with list #6641
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
28f2e4c
list working with click
MichelleArk 75855f7
add --model to subcommands that accept --select
MichelleArk a9ba644
Add generated CLI API docs
FishtownBuildBot 4292c3c
changelog entry
MichelleArk 286efdd
multiple --exclude, no --models option support for build, default for…
MichelleArk 9bb4a26
Add generated CLI API docs
FishtownBuildBot 265bb73
OptionEatAll
MichelleArk 76e4f52
Add generated CLI API docs
FishtownBuildBot 475b69b
use OptionEatAll for --exclude
MichelleArk 54355c6
Add generated CLI API docs
FishtownBuildBot 4840acc
use OptionEatAll with ChoiceTuple for --resource-type
MichelleArk f94847c
Add generated CLI API docs
FishtownBuildBot 8bed1bc
s/OptionEatAll/MultiOption
MichelleArk 9b143d7
Add generated CLI API docs
FishtownBuildBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Under the Hood | ||
body: dbt list working with click | ||
time: 2023-01-17T21:37:29.91632-05:00 | ||
custom: | ||
Author: michelleark | ||
Issue: "5549" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import click | ||
|
||
|
||
# Implementation from: https://stackoverflow.com/a/48394004 | ||
# 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(MultiOption, self).__init__(*args, **kwargs) | ||
self._previous_parser_process = None | ||
self._eat_all_parser = None | ||
|
||
def add_to_parser(self, parser, ctx): | ||
def parser_process(value, state): | ||
# method to hook to the parser.process | ||
done = False | ||
value = [value] | ||
if self.save_other_options: | ||
# grab everything up to the next option | ||
while state.rargs and not done: | ||
for prefix in self._eat_all_parser.prefixes: | ||
if state.rargs[0].startswith(prefix): | ||
done = True | ||
if not done: | ||
value.append(state.rargs.pop(0)) | ||
else: | ||
# grab everything remaining | ||
value += state.rargs | ||
state.rargs[:] = [] | ||
value = tuple(value) | ||
# call the actual process | ||
self._previous_parser_process(value, state) | ||
|
||
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: | ||
self._eat_all_parser = our_parser | ||
self._previous_parser_process = our_parser.process | ||
our_parser.process = parser_process | ||
break | ||
return retval |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matching default value of
"selector"
with what's in main.py on the main branch