Shortened a couple of things in the command system
This commit is contained in:
parent
da1f16b0c9
commit
09e1742bcc
3 changed files with 14 additions and 14 deletions
|
@ -226,9 +226,9 @@ def command(*names, **properties):
|
||||||
can be reached. If no names are given - the the native name (the one
|
can be reached. If no names are given - the the native name (the one
|
||||||
extracted from the command handler) will be used.
|
extracted from the command handler) will be used.
|
||||||
|
|
||||||
If include_native=True is given (default) and names is non-empty -
|
If native=True is given (default) and names is non-empty - then the
|
||||||
then the native name of the command will be prepended in addition to
|
native name of the command will be prepended in addition to the
|
||||||
the given names.
|
given names.
|
||||||
|
|
||||||
If usage=True is given (default) - then command help will be
|
If usage=True is given (default) - then command help will be
|
||||||
appended with autogenerated usage info, based of the command handler
|
appended with autogenerated usage info, based of the command handler
|
||||||
|
@ -256,14 +256,14 @@ def command(*names, **properties):
|
||||||
If overlap=True is given - then all the extra arguments will be
|
If overlap=True is given - then all the extra arguments will be
|
||||||
mapped as if they were values for the keyword arguments.
|
mapped as if they were values for the keyword arguments.
|
||||||
|
|
||||||
If expand_short=True is given (default) - then short, one-letter
|
If expand=True is given (default) - then short, one-letter options
|
||||||
options will be expanded to a verbose ones, based of the comparison
|
will be expanded to a verbose ones, based of the comparison of the
|
||||||
of the first letter. If more then one option with the same first
|
first letter. If more then one option with the same first letter is
|
||||||
letter is given - then only first one will be used in the expansion.
|
given - then only first one will be used in the expansion.
|
||||||
"""
|
"""
|
||||||
names = list(names)
|
names = list(names)
|
||||||
|
|
||||||
include_native = properties.get('include_native', True)
|
native = properties.get('native', True)
|
||||||
|
|
||||||
usage = properties.get('usage', True)
|
usage = properties.get('usage', True)
|
||||||
source = properties.get('source', False)
|
source = properties.get('source', False)
|
||||||
|
@ -271,7 +271,7 @@ def command(*names, **properties):
|
||||||
empty = properties.get('empty', False)
|
empty = properties.get('empty', False)
|
||||||
extra = properties.get('extra', False)
|
extra = properties.get('extra', False)
|
||||||
overlap = properties.get('overlap', False)
|
overlap = properties.get('overlap', False)
|
||||||
expand_short = properties.get('expand_short', True)
|
expand = properties.get('expand', True)
|
||||||
|
|
||||||
if empty and not raw:
|
if empty and not raw:
|
||||||
raise DefinitionError("Empty option can be used only with raw commands")
|
raise DefinitionError("Empty option can be used only with raw commands")
|
||||||
|
@ -286,7 +286,7 @@ def command(*names, **properties):
|
||||||
'extra': extra,
|
'extra': extra,
|
||||||
'overlap': overlap,
|
'overlap': overlap,
|
||||||
'empty': empty,
|
'empty': empty,
|
||||||
'expand_short': expand_short
|
'expand': expand
|
||||||
}
|
}
|
||||||
|
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
|
@ -297,9 +297,9 @@ def command(*names, **properties):
|
||||||
command = Command(handler, *names, **properties)
|
command = Command(handler, *names, **properties)
|
||||||
|
|
||||||
# Extract and inject a native name if either no other names are
|
# Extract and inject a native name if either no other names are
|
||||||
# specified or include_native property is enabled, while making
|
# specified or native property is enabled, while making
|
||||||
# sure it is going to be the first one in the list.
|
# sure it is going to be the first one in the list.
|
||||||
if not names or include_native:
|
if not names or native:
|
||||||
names.insert(0, command.native_name)
|
names.insert(0, command.native_name)
|
||||||
command.names = tuple(names)
|
command.names = tuple(names)
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class StandardCommonCommands(CommandContainer):
|
||||||
self.chat_buttons_set_visible(new_status)
|
self.chat_buttons_set_visible(new_status)
|
||||||
|
|
||||||
@command(overlap=True)
|
@command(overlap=True)
|
||||||
@doc(_("Show help on a given command or a list of available commands if -(-a)ll is given"))
|
@doc(_("Show help on a given command or a list of available commands if -a is given"))
|
||||||
def help(self, command=None, all=False):
|
def help(self, command=None, all=False):
|
||||||
if command:
|
if command:
|
||||||
command = self.get_command(command)
|
command = self.get_command(command)
|
||||||
|
|
|
@ -205,7 +205,7 @@ def adapt_arguments(command, arguments, args, opts):
|
||||||
# The second stage of transforming options to an associatable state.
|
# The second stage of transforming options to an associatable state.
|
||||||
# Expanding short, one-letter options to a verbose ones, if
|
# Expanding short, one-letter options to a verbose ones, if
|
||||||
# corresponding optin has been given.
|
# corresponding optin has been given.
|
||||||
if command.expand_short:
|
if command.expand:
|
||||||
expanded = []
|
expanded = []
|
||||||
for spec_key, spec_value in norm_kwargs.iteritems():
|
for spec_key, spec_value in norm_kwargs.iteritems():
|
||||||
letter = spec_key[0] if len(spec_key) > 1 else None
|
letter = spec_key[0] if len(spec_key) > 1 else None
|
||||||
|
|
Loading…
Add table
Reference in a new issue