code: def do_repl(self):
          
          from prompt_toolkit import prompt
          from prompt_toolkit.history import FileHistory
          from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
          from prompt_toolkit.contrib.completers import WordCompleter
  
          self.options.quiet = False
          proxy = self.open()
          ps1 = proxy.session.name() + u'> '
          words = ['help', 'stats', 'exit']
          words += [x + '=' for x in proxy.system.listMethods()]
          history_file = os.path.join(config.config_dir, '.rtxmlrpc_history')
  
          while True:
              try:
                  try:
                      cmd = prompt(ps1, completer=WordCompleter(words),
                                   auto_suggest=AutoSuggestFromHistory(),
                                   history=FileHistory(history_file))
                  except KeyboardInterrupt:
                      cmd = ''
                  if not cmd:
                      print("Enter '?' or 'help' for usage information, 'Ctrl-D' to exit.")
  
                  if cmd in {'?', 'help'}:
                      self.repl_usage()
                      continue
                  elif cmd in {'', 'stats'}:
                      print(repr(proxy).split(None, 1)[1])
                      continue
                  elif cmd in {'exit'}:
                      raise EOFError()
  
                  try:
                      method, raw_args = cmd.split('=', 1)
                  except ValueError:
                      print("ERROR: '=' not found")
                      continue
  
                  raw_args = raw_args.split(',')
                  args = self.cooked(raw_args)
                  self.execute(proxy, method, args)
              except EOFError:
                  print('Bye from {!r}'.format(proxy))
                  break
docs: REPL for rTorrent XMLRPC commands.