title: Gouping of aliases into their own group
body: <p>I have a <code>tool</code> that manipulates two resources: <code>r1</code> and <code>r2</code>. Each of which has its own click group, with <code>get</code> command inside:</p>
  <pre><code>import click
  
  @click.group
  def cli():
      pass
  
  @cli.group
  def r1():
      pass
  
  @r1.command(&quot;get&quot;)
  def r1_get():
      click.echo(&quot;r1.get&quot;)
  
  @cli.group
  def r2():
      pass
  
  @r2.command(&quot;get&quot;)
  def r2_get():
      click.echo(&quot;r2.get&quot;)
  
  if __name__ == &quot;__main__&quot;:
      from click.utils import get_os_args
  
      cli(get_os_args())
  </code></pre>
  <p>I can invoke commands:</p>
  <pre><code>$ tool r1 get
  r1.get
  $ tool r2 get    
  r2.get
  </code></pre>
  <p>I'd used recipe from <a href="https://stackoverflow.com/a/47985653/38592">https://stackoverflow.com/a/47985653/38592</a> to create aliases:</p>
  <pre><code>aliases = dict(
      r1get='r1 get'.split(),
      r2get='r2 get'.split(),
  )
  @click.group(cls=ExpandAliasesGroup, aliases=aliases)
  def cli():
      pass
  </code></pre>
  <p>This fills root group of my <code>tool</code> with aliases:</p>
  <pre><code>$ tool r1get
  r1.get
  $ tool r2get
  r2.get
  </code></pre>
  <hr />
  <p>I want to enable following:</p>
  <pre><code>$ tool get r1
  r1.get
  $ tool get r2
  r2.get
  </code></pre>
  <p>I'd tried something like this:</p>
  <pre><code>aliases = dict(
      r1='r1 get'.split(),
      r2='r2 get'.split(),
  )
  
  @cli.group(cls=ExpandAliasesGroup, aliases=aliases)
  def get():
      pass
  </code></pre>
  <p>But this does not work, since <code>r1</code> and <code>r2</code> are outside of scope of the <code>get</code> group.</p>
  <pre><code>$ tool get r1
  Error: No such command 'r1'.
  $ tool get r2
  Error: No such command 'r2'.
  </code></pre>
  <p>What should be proper way to group such aliases into its own <code>get</code> group?</p>