title: Completion when program has sub-commands
body: <p>I have written a command-line tool that uses sub-commands much like Mercurial, Git, Subversion &amp;c., in that its general usage is:</p>
  
  <pre><code>&gt;myapp [OPTS] SUBCOMMAND [SUBCOMMAND-OPTS] [ARGS]
  </code></pre>
  
  <p>E.g.</p>
  
  <pre><code>&gt;myapp --verbose speak --voice=samantha --quickly "hello there"
  </code></pre>
  
  <p>I'm now in the process of building Zsh completion for it but have quickly found out that it is a very complex beast. I have had a look at the <code>_hg</code> and <code>_git</code> completions but they are very complex and different in approach (I struggle to understand them), but both seem to handle each sub-command separately.</p>
  
  <p>Does anyone know if there a way using the built in functions (<code>_arguments</code>, <code>_values</code>, <code>pick_variant</code> &amp;c.) to handle the concept of sub-commands correctly, including handling general options and sub-command specific options appropriately? Or would the best approach be to manually handle the general options and sub-command?</p>
  
  <p>A noddy example would be very much appreciated.</p>
  
  <p>Many thanks.</p>