title: argparse optional subparser (for --version)
body: <p>I have the following code (using Python 2.7):</p>
  
  <pre><code># shared command line options, like --version or --verbose
  parser_shared = argparse.ArgumentParser(add_help=False)
  parser_shared.add_argument('--version', action='store_true')
  
  # the main parser, inherits from `parser_shared`
  parser = argparse.ArgumentParser(description='main', parents=[parser_shared])
  
  # several subcommands, which can't inherit from the main parser, since
  # it would expect subcommands ad infinitum
  subparsers = parser.add_subparsers('db', parents=[parser_shared])
  
  ...
  
  args = parser.parse_args()
  </code></pre>
  
  <p>Now I would like to be able to call this program e.g. with the <code>--version</code> appended to the normal program or some subcommand:</p>
  
  <pre><code>$ prog --version
  0.1
  
  $ prog db --version
  0.1
  </code></pre>
  
  <p>Basically, I need to declare optional subparsers. I'm aware that this isn't <a href="http://bugs.python.org/issue9253" rel="noreferrer">really supported</a>, but are there any workarounds or alternatives?</p>
  
  <p>Edit: The error message I am getting:</p>
  
  <pre><code>$ prog db --version
  # works fine
  
  $ prog --version
  usage: ....
  prog: error: too few arguments
  </code></pre>