docs: def mainloop(self):
          """ The main loop.
          """
          if len(self.args) == 1 and "=urn:btih:" in self.args[0]:
              # Handle magnet link
              self.make_magnet_meta(self.args[0])
              return
  
          if not self.args:
              self.parser.print_help()
              self.parser.exit()
          elif len(self.args) < 2:
              self.parser.error("Expected a path and at least one announce URL, got: %s" % (' '.join(self.args),))
  
          # Create and configure metafile factory
          datapath = self.args[0].rstrip(os.sep)
          metapath = datapath
          if self.options.output_filename:
              metapath = self.options.output_filename
              if os.path.isdir(metapath):
                  metapath = os.path.join(metapath, os.path.basename(datapath))
          if not metapath.endswith(".torrent"):
              metapath += ".torrent"
          torrent = metafile.Metafile(metapath)
          torrent.ignore.extend(self.options.exclude)
  
          def callback(meta):
              "Callback to set label and resume data."
              if self.options.cross_seed:
                  if self.options.cross_seed == "@entropy":
                      meta["info"]["entropy"] = format(random.getrandbits(self.ENTROPY_BITS),
                                                       'x').zfill(self.ENTROPY_BITS//4)
                  else:
                      meta["info"]["x_cross_seed_label"] = self.options.cross_seed
              if self.options.no_cross_seed:
                  del meta["info"]["x_cross_seed"]
  
              # Set specific keys?
              metafile.assign_fields(meta, self.options.set)
  
          # Create and write the metafile(s)
          # TODO: make it work better with multiple trackers (hash only once), also create fast-resume file for each tracker
          meta = torrent.create(datapath, self.args[1:],
              progress=None if self.options.quiet else metafile.console_progress(),
              root_name=self.options.root_name, private=self.options.private, no_date=self.options.no_date,
              comment=self.options.comment, created_by="PyroScope %s" % self.version, callback=callback
          )
  
          # Create second metafile with fast-resume?
          if self.options.hashed:
              try:
                  metafile.add_fast_resume(meta, datapath)
              except EnvironmentError as exc:
                  self.fatal("Error making fast-resume data (%s)" % (exc,))
                  raise
  
              hashed_path = re.sub(r"\.torrent$", "", metapath) + "-resume.torrent"
              self.LOG.info("Writing fast-resume metafile %r..." % (hashed_path,))
              try:
                  bencode.bwrite(hashed_path, meta)
              except EnvironmentError as exc:
                  self.fatal("Error writing fast-resume metafile %r (%s)" % (hashed_path, exc,))
                  raise