code: def parser(description=None, usage=None):
      
  
      class ArgNamespace(object):
          def __init__(self, result):
              self._result = result
  
          def __getattr__(self, name):
              try:
                  super(ArgNamespace, self).__getattr__(name)
              except AttributeError:
                  return getattr(self._result, name)
  
          def arg_strings(self, name=None):
              if not self._result:
                  return None
              return extract_strings(self._result.__dict__, name)
  
      class ArgParser(object):
  
          def __init__(self, argument_parser):
              self.parser = argument_parser
              self.parse = self.parse_args
              self._parsed = None
  
              self.arg = self.parser.add_argument
              self.opt = self.true = partial(self.arg, action='store_true')
              self.int = partial(self.arg, type=int)
  
          def parse_args(self):
              return ArgNamespace(self.parser.parse_args())
  
          def sub(self, name, help=''):
              self.arg(name, metavar=name, help=help, type=str)
  
          def args(self, name, help='', many='*'):
              self.arg(name, metavar=name, help=help, type=str, nargs=many)
  
          def answer(self, answers=None):
              yes_no = {
                  'n': ('-n', '--no', 'Answer no'),
                  'y': ('-y', '--yes', 'Answer yes'),
              }
              options = yes_no
              options.update(answers)
              [self.true(options[o]) for o in options]
  
      lines = description.splitlines()
      if not usage:
          if len(lines) > 1 and not lines[1]:
              usage, epilog = lines[0], '\n\n'.join(lines[2:])
      else:
          usage = description = lines[0]
          epilog = None
      return ArgParser(
          argparse.ArgumentParser(usage=description))
docs: Parse out command line arguments