class EnClient::Shell

Constants

AUTO_SYNC_INTERVAL

Public Instance Methods

reply(command, reply) click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 1846
def reply(command, reply)
  reply.command_id = command.command_id
  $stdout.write Formatter.obj_to_sexp(reply)
  $stdout.flush
end
run() click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 1805
def run
  sm = SessionManager.new
  dm = DBManager.new
  tm = TaskManager.new
  tm.run

  Thread.start do
    Timer.repeat_every AUTO_SYNC_INTERVAL do
      tm.put SyncTask.new(sm, dm, tm)
    end
  end

  begin
    #if $stdin.respond_to? :set_encoding
    #  LOG.debug "get stdin encoding #{$stdin.external_encoding}, #{$stdin.internal_encoding}"
    #  $stdin.set_encoding "UTF-8", "UTF-8"
    #  $stdout.set_encoding "UTF-8", "UTF-8"
    #  LOG.debug "get stdin encoding #{$stdin.external_encoding}, #{$stdin.internal_encoding}"
    #end
    while true
      begin
        line = $stdin.gets "\000"
        hash = eval line
        LOG.debug "<#{hash[:class]}>"
        command = Command.create_from_hash hash
        command.sm = sm
        command.dm = dm
        command.tm = tm
        command.shell = self
        command.exec
      rescue SyntaxError
        LOG.error $!.backtrace
      rescue
        LOG.error $!.backtrace
      end
    end
  rescue Interrupt
    LOG.debug "Interrupted"
  end
end