Merge branch '6.x-maintenance'
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 · parents a6a6964, 226ae62 · Browse files · 5 files·+38 added−27 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+38 added−27 removed
- tests:+1 added−0 removed
- other:+37 added−27 removed
Provenance
- Commit
6fcda3e- Tree
fbd068c- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
a6a6964- Parent 2
226ae62
5 files changed+38 added−27 removed
modified:click/core.py+24 added
35 unmodified lines36 if bashcomplete(cmd, prog_name, complete_var, complete_instr):37 sys.exit(1)38 39 40+def _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"). This restriction was supposed to '53+ 'be lifted in 6.0 but the fix was flawed. This '54+ 'will be fixed in Click 7.0' % (55+ hint, base_command.name, cmd_name,56+ cmd_name, cmd.__class__.__name__,57+ base_command.__class__.__name__,58+ base_command.name))59+60+61 def batch(iterable, batch_size):62 return list(zip(*repeat(iter(iterable), batch_size)))63 64 1078 unmodified lines1143 """1144 name = name or cmd.name1145 if name is None:1146 raise TypeError('Command has no name.')1147+ _check_multicommand(self, name, cmd, register=True)1148 self.commands[name] = cmd1149 1150 def command(self, *args, **kwargs):1151 """A shortcut decorator for declaring and attaching a command to45 unmodified lines1197 def get_command(self, ctx, cmd_name):1198 for source in self.sources:1199 rv = source.get_command(ctx, cmd_name)1200 if rv is not None:1201+ if self.chain:1202+ _check_multicommand(self, cmd_name, rv)1203 return rv1204 1205 def list_commands(self, ctx):1206 rv = set()532 unmodified linesmodified:click/exceptions.py+7 added-6 removed
114 unmodified lines115 if param_type is None and self.param is not None:116 param_type = self.param.param_type_name117 118 msg = self.message119+ if self.param is not None:119- msg_extra = self.param.type.get_missing_message(self.param)120- if msg_extra:121- if msg:122- msg += '. ' + msg_extra123- else:124- msg = msg_extra120+ msg_extra = self.param.type.get_missing_message(self.param)121+ if msg_extra:122+ if msg:123+ msg += '. ' + msg_extra124+ else:125+ msg = msg_extra126 127 return 'Missing %s%s%s%s' % (128 param_type,129 param_hint and ' %s' % param_hint or '',72 unmodified linesmodified:docs/commands.rst+3 added-20 removed
319 unmodified lines320 one command is invoked. This is necessary because the handling of321 subcommands happens one after another so the exact subcommands that will322 be handled are not yet available when the callback fires.323 324+.. note::325 325-Nested Group Commands with Chaining326------------------------------------326+ It is currently not possible for chain commands to be nested. This327+ will be fixed in future versions of Click.328 328-.. versionadded:: 6.0329 330-Before Click 6 it was not possible for chain commands to be nested as331-behavior was not entirely defined. In Click 6 this has been corrected332-and group commands can now be nested below chain commands. The following333-logic applies as a result:334-335-* if a chain command is used below a chain command it will not be336- possible for the outer command to accept any more arguments with the337- start of the sub command. This is done in order to ensure that338- commands do not change behavior when nested below other commands.339-* Click now internally has the concept of protected arguments which is340- what is used to ensure nested parsing does not accidentally mix341- rest arguments intended for the callbacks with leftover arguments for342- parsing. This change has cleaned up some accidental bugs in the past343- where the context showed arguments that were not actually intended for344- the command.345-346-330 Multi Command Pipelines331 -----------------------332 333 .. versionadded:: 3.0225 unmodified linesmodified:tests/test_chain.py+1 added
218 unmodified lines219 'a',220 ]221 222 223+@pytest.mark.xfail224 def test_multicommand_chaining(runner):225 @click.group(chain=True)226 def cli():227 debug()25 unmodified linesmodified:CHANGES+3 added-1 removed
9 unmodified lines10 11 Version 6.112 -----------13 14-(bugfix release, release date to be decided)14+(bugfix release, released on November 27th 2015)15 16 - Resolved an issue with invisible progress bars no longer rendering.17+- Disable chain commands with subcommands as they were inherently broken.18+- Fix `MissingParameter` not working without parameters passed.19 20 Version 6.021 -----------22 291 unmodified lines