Figure out which of the two options was used (build, get) and dispatch.

  :param args:      the arguments for this script, as a list of string. Should
                    already have had the script name stripped, so we expect the
                    first item in this list to specify the mode ('build' an
                    index or 'get' elements from an indexed file).
  :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(args=[], prog_name=sys.argv[0]):
  """Figure out which of the two options was used (build, get) and dispatch.

  :param args:      the arguments for this script, as a list of string. Should
                    already have had the script name stripped, so we expect the
                    first item in this list to specify the mode ('build' an
                    index or 'get' elements from an indexed file).
  :param prog_name: the name of the script; taken from command line args by
                    default, but you can change it if you want.
  """
  helpStr = "Build indexes and use them to extract elements from         \n" +\
            "indexed files on-demand.                                    \n" +\
            "                                                            \n" +\
            "------------------------------------------------------------\n" +\
            "                      BUILDING AN INDEX                     \n" +\
            "------------------------------------------------------------\n" +\
            "                                                            \n" +\
            "To build an index for a file called foo.maf, where $ is     \n" +\
            "your prompt:                                                \n" +\
            "                                                            \n" +\
            "$ pyokit index build -o foo.idx foo.maf                     \n" +\
            "                                                            \n" +\
            "for more information about the build command, where $ is    \n" +\
            "your prompt, run:                                           \n" +\
            "                                                            \n" +\
            "$ pyokit index build --help                                 \n" +\
            "                                                            \n" +\
            "------------------------------------------------------------\n" +\
            "                           LOOKUP                           \n" +\
            "------------------------------------------------------------\n" +\
            "To run interactive lookup of values using an index , where $\n" +\
            "is your prompt:                                             \n" +\
            "                                                            \n" +\
            "$ pyokit index lookup foo.maf foo.idx                       \n" +\
            "                                                            \n" +\
            "for more information about the lookup command, where $ is   \n" +\
            "your prompt, run:                                           \n" +\
            "                                                            \n" +\
            "$ pyokit index lookup --help                                \n" +\
            "                                                              "

  if len(args) == 0 or (len(args) == 1 and isHelpString(args[0])):
    sys.stderr.write(helpStr + "\n\n")
  else:
    arg_one = args[0].strip().lower()
    if arg_one == "build":
      main_build_index(args[1:])
    elif arg_one == "lookup":
      main_lookup_index(args[1:])
    else:
      raise PyokitUIError("Unknown option " + arg_one)