title: How to Set a Default Subparser using Argparse Module with Python 2.7
body: <p>I'm using Python 2.7 and I'm trying to accomplish a shell like behavior using argparse.
  My issue, in general, that I cannot seem to find a way, in Python 2.7, to use argparse's subparsers as optional.
  It's kind of hard to explain my issue so I'll describe what I require from my program.</p>
  
  <p>The program has 2 modes of work:</p>
  
  <ol>
  <li>Starting the program with a given command (each command has it's own
  additional arguments) and additional arguments will run a specific
  task. </li>
  <li>Starting the program without a command will start a shell-like program that can take a line of arguments and process them as if the
  program was called with the given line as it's arguments.</li>
  </ol>
  
  <p>So, if for example my program supports 'cmd1' and 'cmd2' commands, I could use it like so:</p>
  
  <ul>
  <li><code>python program.py cmd1 additional_args1</code></li>
  <li><code>python program.py cmd2 additional_args2</code></li>
  </ul>
  
  <p>or with shell mode:</p>
  
  <ul>
  <li><code>python program.py</code>
  
  <ul>
  <li><code>cmd1 additional_args1</code></li>
  <li><code>cmd2 additional_args2</code></li>
  <li><code>quit</code></li>
  </ul></li>
  </ul>
  
  <p>In addition, I also want my program to be able to take optional global arguments that will effect all commands.</p>
  
  <p>For that I'm using argparse like so (This is a pure example):</p>
  
  <pre><code>parser = argparse.ArgumentParser(description="{} - Version {}".format(PROGRAM_NAME, PROGRAM_VERSION))
  
  parser.add_argument("-i", "--info",  help="Display more information")
  
  subparsers = parser.add_subparsers()
  
  parserCmd1 = subparsers.add_parser("cmd1", help="First Command")
  parserCmd1.set_defaults(func=cmd1)
  
  parserCmd2 = subparsers.add_parser("cmd2", help="Second Command")
  parserCmd2.add_argument("-o", "--output", help="Redirect Output")
  parserCmd2.set_defaults(func=cmd2)
  </code></pre>
  
  <p>So I can call cmd1 (with no additional args) or cmd2 (with or without -o flag). And for both I can add flag -i to display even more information of the called command.</p>
  
  <p>My issue is that I cannot activate shell mode, because I have to provide cmd1 or cmd2 as an argument (because of using subparsers which are mandatory)</p>
  
  <p>Restrictions:</p>
  
  <ul>
  <li>I cannot use Python 3 (I know it can be easily done there)</li>
  <li>Because of global optional arguments I cannot check to see if I get no arguments to skip arg parsing.</li>
  <li>I don't want to add a new command to call shell, it must be when providing no command at all</li>
  </ul>
  
  <p>So how can I achieve This kind of behavior with argparse and python 2.7?</p>