Skip to content

Commit

Permalink
Hide 'flag options' from autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
vvd170501 committed Sep 13, 2023
1 parent 9252a5f commit c60f829
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.16.24'
__version__ = '1.16.25'
8 changes: 8 additions & 0 deletions kks/util/click.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ class FlagOption(click.Option):

class OptFlagOption(click.Option):
""" Fix the help for the _opt suffix """
def __init__(self, *args, **kwargs):
# To hide '--optionname_opt' from autocompletoon
# Assuming that 'hidden', if present, is always in kwargs (in click 8.1 it's the 14th arg)
kwargs['hidden'] = True
super().__init__(*args, **kwargs)

def get_help_record(self, ctx):
self.hidden = False
help = super().get_help_record(ctx)
self.hidden = True
return (help[0].replace('_opt ', '='),) + help[1:]

def get_error_hint(self, ctx):
Expand Down

0 comments on commit c60f829

Please sign in to comment.