main entry point for the index script.

  :param args:      the arguments for this script, as a list of string. Should
                    already have had the script name stripped. That is, if
                    there are no args provided, this should be an empty list.
  :param prog_name: the name of the script; taken from command line args by
                    default, but you can change it if you want.

def main_lookup_index(args=[], prog_name=sys.argv[0]):
  """
  main entry point for the index script.

  :param args:      the arguments for this script, as a list of string. Should
                    already have had the script name stripped. That is, if
                    there are no args provided, this should be an empty list.
  :param prog_name: the name of the script; taken from command line args by
                    default, but you can change it if you want.
  """
  # get options and arguments
  ui = getUI_lookup_index(prog_name, args)

  # just run unit tests
  if ui.optionIsSet("test"):
    unittest.main(argv=[sys.argv[0]])
    sys.exit()

  # just show help
  if ui.optionIsSet("help"):
    ui.usage()
    sys.exit()
  verbose = (ui.optionIsSet("verbose") is True) or DEFAULT_VERBOSITY

  # required exactly two args, so this should be fine.
  in_indexed, in_index = open(ui.getArgument(0)), open(ui.getArgument(1))

  # Get output handle(s). If only one input file, and no output file, output
  # to standard out.
  out_fh = sys.stdout
  if ui.optionIsSet("output"):
    out_fh = open(ui.getValue("output"), "w")

  # get the lookup key
  key = None
  if ui.optionIsSet("key"):
    key = ui.getValue("key")

  # figure out which indexer to use and then index each file
  op_val = ui.getValue("type") if ui.optionIsSet("type") else None
  lookup_func = __get_lookup(ui.getArgument(0), op_val)

  lookup_func(in_index, in_indexed, out_fh, key, verbose)