title: How to implement multiple subcommands with Yargs?
body: <p>I've been trying and trying, but just couldn't digest Yargs' <a href="http://yargs.js.org/docs/" rel="noreferrer">docs</a>.</p>
  
  <p>I need to create a set of commands/subcommands:</p>
  
  <pre><code>~$framework generate routed-module ModuleOne ModuleTwo ModuleThree --animation-style=bounce-up
  
  //would call a handler with:
  { modules: string[], options: {animationStyle?: AnimationStyle}}
  type AnimationStyle = 'bounce-up' | 'slide-left'
  
  </code></pre>
  
  <p>or</p>
  
  <pre><code>~$framework generate stateful-ui ModuleOne ModuleTwo ModuleThree
  //would call a handler with:
  { modules: string[]}
  
  </code></pre>
  
  <p>or</p>
  
  <pre><code>~$framework init
  //would just call a handler
  </code></pre>
  
  <p>I'd like aliases: 
  <code>g</code> for <code>generate</code>,
  <code>r</code> for <code>routed-module</code>,
  <code>s</code> for <code>stateful-ui</code>.</p>
  
  <p>Autocompletion would be nice.</p>
  
  <p>Here's what I've tried, don't know where to go from here:</p>
  
  <pre><code>  yargs
      .scriptName('elm-framework')
      .command({
        command: 'generate [moduleType] [moduleNames]',
        aliases: ['g'],
        describe: 'Generates a resource',
        handler: config.handleModuleGeneration,
        builder: {
          moduleType: {
            demand: true,
            choices: ['routed', 'stateful'] as const,
            default: 'routed',
          },
          moduleNames: {
            demand: true,
            array: true,
          },
        },
      })
  </code></pre>
  
  <p>Thanx!</p>
  
  <p>(Doing this with typescript is not necessary. I primarily want to understand how to use the library's api.)</p>