title: argparse function arguments
body: <p>I am trying to use argparse to create my script with parameters but I am not being able to.</p>
  
  <p>The name of my script is <code>pipeline</code> and it has some options arguments like -b, -c, -i and -r.</p>
  
  <p>If you call the script <code>./pipeline -b</code> should give an error asking for a git repository path but I am not being able to do this.</p>
  
  <pre><code>from git import Repo
  import os
  import sys
  import subprocess
  import argparse
  
  class Ci:
  
      def build(self,args):
          cloned_repo = Repo.clone_from(args)
          print("clonning repository " + args)
          cloned_repo
  
          dir = git.split('/')(-1)
  
          if os.path.isdir(dir):
              print("repository cloned successfully")
          else:
              print("error to clone repository")
  
  
  if __name__ == '__main__':
  
      parser = argparse.ArgumentParser()
  
      parser.add_argument('-b','-build',action='store_true', help='execute mvn clean install')
      parser.add_argument('-c','-compress',action='store_true',help='zip a directory recursively')
      parser.add_argument('-i','-integration',action='store_true',help='execute mvn verify')
      parser.add_argument('-r','-release',action='store_true',help='execute build,integration and compress respectively')
      args = parser.parse_args()
  
      if args.b:
          a = Ci()
          a.build()
  
      if len(sys.argv) &lt; 2:
          parser.print_help()
          sys.exit(1)
  </code></pre>
  
  <p>I can't make this sub-parameter work and I can't find a way to pass this parameter to my <code>build</code> function.</p>
  
  <p>e.g:</p>
  
  <pre class="lang-none prettyprint-override"><code>./pipeline -b
  
  Output: error missins git path
  ./pipeline -b https://git/repo
  Output: clonning repo
  </code></pre>
  
  <p>and the string <code>"https://git/repo"</code> has to be passed as the argument to my  <code>build</code> function:</p>
  
  <p>How can I make it work?</p>