Skip to content
Myr

Simplified internal parser API

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent e0d4520 · Browse files · 2 files+7 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−7 removed

  • other:+7 added−7 removed

2 files+7 added−7 removed

modified:click/core.py+4 added-4 removed
884 unmodified lines
885886 if self.is_flag:887 kwargs.pop('nargs', None)888 if self.is_bool_flag and self.secondary_opts:889 parser.add_option(*self.opts, action=action + '_const',889 parser.add_option(self.opts, action=action + '_const',890 const=True, **kwargs)891 kwargs.pop('default', None)892 parser.add_option(*self.secondary_opts, action=action +892 parser.add_option(self.secondary_opts, action=action +893 '_const', const=False, **kwargs)894 else:895 parser.add_option(*self.opts, action=action + '_const',895 parser.add_option(self.opts, action=action + '_const',896 const=self.flag_value,897 **kwargs)898 else:899 kwargs['action'] = action900 parser.add_option(*self.opts, **kwargs)900 parser.add_option(self.opts, **kwargs)901902 def get_help_record(self, ctx):903 def _write_opts(opts):904 rv = []
110 unmodified lines
modified:click/parser.py+3 added-3 removed
22 unmodified lines
23 ATTRS = ('action', 'type', 'dest', 'nargs', 'const')24 TYPED_ACTIONS = ('store', 'append')25 TAKES_VALUE_ACTIONS = ('store', 'append')2627 def __init__(self, *opts, **attrs):27 def __init__(self, opts, **attrs):28 self._short_opts = []29 self._long_opts = []3031 for opt in opts:
44 unmodified lines
76 self._long_opt = {}77 self._arg_dest = []78 self._nargs = []7980 def add_option(self, *args, **kwargs):81 option = Option(*args, **kwargs)80 def add_option(self, opts, **kwargs):81 option = Option(opts, **kwargs)82 for opt in option._short_opts:83 self._short_opt[opt] = option84 for opt in option._long_opts:85 self._long_opt[opt] = option
162 unmodified lines