|
|
@ -179,6 +179,12 @@ class Command(_BaseCommand): |
|
|
|
in a completely raw matter. Defaults to ``False``. |
|
|
|
invoked_subcommand: Optional[:class:`Command`] |
|
|
|
The subcommand that was invoked, if any. |
|
|
|
require_var_positional: :class:`bool` |
|
|
|
If ``True`` and a variadic positional argument is specified, requires |
|
|
|
the user to specify at least one argument. Defaults to ``False``. |
|
|
|
|
|
|
|
.. versionadded:: 1.5 |
|
|
|
|
|
|
|
ignore_extra: :class:`bool` |
|
|
|
If ``True``\, ignores extraneous strings passed to a command if all its |
|
|
|
requirements are met (e.g. ``?foo a b c`` when only expecting ``a`` |
|
|
@ -260,6 +266,7 @@ class Command(_BaseCommand): |
|
|
|
finally: |
|
|
|
self._max_concurrency = max_concurrency |
|
|
|
|
|
|
|
self.require_var_positional = kwargs.get('require_var_positional', False) |
|
|
|
self.ignore_extra = kwargs.get('ignore_extra', True) |
|
|
|
self.cooldown_after_parsing = kwargs.get('cooldown_after_parsing', False) |
|
|
|
self.cog = None |
|
|
@ -699,6 +706,8 @@ class Command(_BaseCommand): |
|
|
|
kwargs[name] = await self.transform(ctx, param) |
|
|
|
break |
|
|
|
elif param.kind == param.VAR_POSITIONAL: |
|
|
|
if view.eof and self.require_var_positional: |
|
|
|
raise MissingRequiredArgument(param) |
|
|
|
while not view.eof: |
|
|
|
try: |
|
|
|
transformed = await self.transform(ctx, param) |
|
|
@ -1009,7 +1018,10 @@ class Command(_BaseCommand): |
|
|
|
result.append('[%s]' % name) |
|
|
|
|
|
|
|
elif param.kind == param.VAR_POSITIONAL: |
|
|
|
result.append('[%s...]' % name) |
|
|
|
if self.require_var_positional: |
|
|
|
result.append('<%s...>' % name) |
|
|
|
else: |
|
|
|
result.append('[%s...]' % name) |
|
|
|
elif greedy: |
|
|
|
result.append('[%s]...' % name) |
|
|
|
elif self._is_typing_optional(param.annotation): |
|
|
|