docs: def results(project, apikey, run, watch, server, output):
      """
      Check to see if results are available for a particular mapping
      and if so download.
  
      Authentication is carried out using the --apikey option which
      must be provided. Depending on the server operating mode this
      may return a mask, a linkage table, or a permutation. Consult
      the entity service documentation for details.
      """
  
      status = run_get_status(server, project, run, apikey)
      log(format_run_status(status))
      if watch:
          for status in watch_run_status(server, project, run, apikey, 24*60*60):
              log(format_run_status(status))
  
      if status['state'] == 'completed':
          log("Downloading result")
          response = run_get_result_text(server, project, run, apikey)
          log("Received result")
          print(response, file=output)
      elif status['state'] == 'error':
          log("There was an error")
          error_result = run_get_result_text(server, project, run, apikey)
          print(error_result, file=output)
      else:
          log("No result yet")