diff options
author | Felix Nordén <felixnorden@gmail.com> | 2020-10-17 12:17:10 +0200 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-10-31 19:58:23 -0700 |
commit | b964c1e2cba3915983a6e2f5fcb7f489acd9b33f (patch) | |
tree | 3146ab125b245935a14d68ed05568181c70b7e68 /src/click | |
parent | acc91bc4f47e38f43277fcdfd8ca855734c4fbbc (diff) | |
download | click-b964c1e2cba3915983a6e2f5fcb7f489acd9b33f.tar.gz |
handle case_sensitive=False when completing choices
Co-authored-by: David Lord <davidism@gmail.com>
Diffstat (limited to 'src/click')
-rw-r--r-- | src/click/types.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/click/types.py b/src/click/types.py index 8c886d6..626287d 100644 --- a/src/click/types.py +++ b/src/click/types.py @@ -274,7 +274,14 @@ class Choice(ParamType): from click.shell_completion import CompletionItem str_choices = map(str, self.choices) - return [CompletionItem(c) for c in str_choices if c.startswith(incomplete)] + + if self.case_sensitive: + matched = (c for c in str_choices if c.startswith(incomplete)) + else: + incomplete = incomplete.lower() + matched = (c for c in str_choices if c.lower().startswith(incomplete)) + + return [CompletionItem(c) for c in matched] class DateTime(ParamType): |