code: def main():
      
      options = parse(sys.argv[1:], CLIRULES, ".splunkrc")
  
      if options.kwargs['omode'] not in OUTPUT_MODES:
          print("output mode must be one of %s, found %s" % (OUTPUT_MODES,
                options.kwargs['omode']))
          sys.exit(1)
  
      service = connect(**options.kwargs)
  
      if path.exists(options.kwargs['output']):
          if not options.kwargs['recover']:
              print("Export file %s exists, and recover option nor specified" % \
                    options.kwargs['output'])
              sys.exit(1)
          else:
              options.kwargs['end'] = recover(options)
              options.kwargs['fixtail'] = True
              openmode = "a"
      else:
          openmode = "w"
          options.kwargs['fixtail'] = False
          
      try:
          options.kwargs['fd'] = open(options.kwargs['output'], openmode)
      except IOError:
          print("Failed to open output file %s w/ mode %s" % \
                               (options.kwargs['output'], openmode))
          sys.exit(1)
  
      export(options, service)
docs: main entry