title: How do I specify two required arguments, including a subcommand, using 'argparse'?
body: <p>Is there a way to specify two required arguments in <a href="https://docs.python.org/2/library/argparse.html#module-argparse" rel="nofollow"><code>argparse</code></a>, one that corresponds to a subcommand, and another that is required by all subcommands.</p>
  
  <p>The closest I can manage seems to be with</p>
  
  <pre><code>import argparse
  
  parser = argparse.ArgumentParser()
  
  subparsers = parser.add_subparsers(help='', dest='command',  metavar='COMMAND', title='required arguments',
                                     description='two arguments are required')
  parser.add_argument('config', metavar='CONFIG', action='store', help='the config to use')
  
  cmda_parser = subparsers.add_parser('cmdA',  help='a first command')
  cmdb_parser = subparsers.add_parser('cmdB',  help='the second operation')
  cmdc_parser = subparsers.add_parser('cmdC',  help='yet another thing')
  
  print(parser.parse_args())
  </code></pre>
  
  <p>which gives</p>
  
  <pre><code>usage: enigma.py [-h] COMMAND ... CONFIG
  
  positional arguments:
    CONFIG      the config to use
  
  optional arguments:
    -h, --help  show this help message and exit
  
  required arguments:
    two arguments are required
  
    COMMAND
      cmdA      a first command
      cmdB      the second operation
      cmdC      yet another thing
  </code></pre>
  
  <p>and help for subcommands that does not show <code>CONFIG</code>; but what I want is</p>
  
  <pre><code>usage: enigma.py [-h] COMMAND CONFIG
  
  required arguments:
    two arguments are required
  
    COMMAND
      cmdA      a first command
      cmdB      the second operation
      cmdC      yet another thing
  
    CONFIG      the config to use
  
  optional arguments:
    -h, --help  show this help message and exit
  </code></pre>
  
  <p>and help for each subcommand that does show <code>CONFIG</code>, eg.</p>
  
  <pre><code>usage: enigma.py cmdA CONFIG [-h] 
  
      required arguments:
  
        CONFIG      the config to use
  
  optional arguments:
    -h, --help  show this help message and exit
  </code></pre>
  
  <p>is there any way to accomplish this?</p>
  
  <p>How to I specific <em>two</em> required arguments, one of which is a subcommand, with the second "propagated" to each subcommand as a required argument?</p>