title: Command line interface with multiple commands using click: add unspecified options for command as dictionary
body: <p>I have a command line interface build with click which implements multiple commands.</p>
  
  <p>Now I want to pass unspecified named options into one command which is here named <code>command1</code> e.g. the number of options and their names should be able to vary flexibly.</p>
  
  <pre><code>import click
  
  
  @click.group(chain=True)
  @click.pass_context
  def cli(ctx, **kwargs):
      return True
  
  
  @cli.command()
  @click.option('--command1-option1', type=str)
  @click.option('--command1-option2', type=str)
  @click.pass_context
  def command1(ctx, **kwargs):
      """Add command1."""
      ctx.obj['command1_args'] = {}
      for k, v in kwargs.items():
          ctx.obj['command1_args'][k] = v
      return True
  
  
  @cli.command()
  @click.argument('command2-argument1', type=str)
  @click.pass_context
  def command2(ctx, **kwargs):
      """Add command2."""
      print(ctx.obj)
      print(kwargs)
      return True
  
  
  if __name__ == '__main__':
      cli(obj={})
  </code></pre>
  
  <p>I have already looked into <a href="http://click.palletsprojects.com/en/7.x/advanced/#forwarding-unknown-options" rel="nofollow noreferrer">forwarding unknown options</a> like in <a href="https://stackoverflow.com/questions/32944131/add-unspecified-options-to-cli-command-using-python-click">this question</a> but the problem is that I have to call (chanin) other commands after the first one which have to be asserted e.g. this call has to work but with arbitrary options for <code>command1</code>:</p>
  
  <pre><code>$python cli.py command1 --command1-option1 foo --command1-option2 bar command2 'hello'
  </code></pre>
  
  <p>So how can I add unspecified named options to a single command and call (chain) another one at the same time (after it)?</p>