Skip to content
Myr

We're not rejecting multi commands below chained multi commands. This fixes #415

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 c4c9eb2 · Browse files · 3 files+27 added−1 removed
This commit

State

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

Diff stats

3 files+27 added−1 removed

  • other:+27 added−1 removed

3 files+27 added−1 removed

modified:click/core.py+22 added
35 unmodified lines
36 if bashcomplete(cmd, prog_name, complete_var, complete_instr):37 sys.exit(1)383940def _check_multicommand(base_command, cmd_name, cmd, register=False):41 if not base_command.chain or not isinstance(cmd, MultiCommand):42 return43 if register:44 hint = 'It is not possible to add multi commands as children to ' \45 'another multi command that is in chain mode'46 else:47 hint = 'Found a multi command as subcommand to a multi command ' \48 'that is in chain mode. This is not supported'49 raise RuntimeError('%s. Command "%s" is set to chain and "%s" was '50 'added as subcommand but it in itself is a '51 'multi command. ("%s" is a %s within a chained '52 '%s named "%s")' % (53 hint, base_command.name, cmd_name,54 cmd_name, cmd.__class__.__name__,55 base_command.__class__.__name__,56 base_command.name))575859def batch(iterable, batch_size):60 return list(zip(*repeat(iter(iterable), batch_size)))6162
1066 unmodified lines
1129 """1130 name = name or cmd.name1131 if name is None:1132 raise TypeError('Command has no name.')1133 _check_multicommand(self, name, cmd, register=True)1134 self.commands[name] = cmd11351136 def command(self, *args, **kwargs):1137 """A shortcut decorator for declaring and attaching a command to
44 unmodified lines
11821183 def get_command(self, ctx, cmd_name):1184 for source in self.sources:1185 rv = source.get_command(ctx, cmd_name)1186 if self.chain:1187 _check_multicommand(self, cmd_name, rv)1188 if rv is not None:1189 return rv11901191 def list_commands(self, ctx):
527 unmodified lines
modified:docs/commands.rst+2 added-1 removed
308 unmodified lines
309310 invoke(cli, prog_name='setup.py', args=['sdist', 'bdist_wheel'])311312When using multi command chaining you can only have one command (the last)313use ``nargs=-1`` on an argument. Other than that there are no313use ``nargs=-1`` on an argument. It is also not possible to nest multi314commands below chained multicommands. Other than that there are no315restrictions on how they work. They can accept options and arguments as316normal.317318Another note: the :attr:`Context.invoked_subcommand` attribute is a bit
235 unmodified lines
modified:CHANGES+3 added
8 unmodified lines
9(codename and release date to be decided)1011- Optimized the progressbar rendering to not render when it did not12 actually change.13- Actively reject multi commands within chained multi commands. This14 cannot be supported with the current setup of how the invocation for15 subcommands works.1617Version 5.118-----------19
251 unmodified lines