warden/lib/warden/repl/repl_v2.rb
# Starts an interactive client that uses the 'warden> ' prompt to accept
# commands interactively. Autocompletes commands on the prompt when the tab
# key is pressed. Writes the output of the command to standard out and
# errors to standard error. Also saves and restores the command history
# from a specified file.
#
# If error_on_exit flag is set, then returns an integer representing the
# exit status (if any) returned by the last command that was executed
# successfully. Otherwise, returns zero.
Starts an interactive client that uses the 'warden> ' prompt to accept
commands interactively. Autocompletes commands on the prompt when the tab
key is pressed. Writes the output of the command to standard out and
errors to standard error. Also saves and restores the command history
from a specified file.

If error_on_exit flag is set, then returns an integer representing the
exit status (if any) returned by the last command that was executed
successfully. Otherwise, returns zero.
Starts an interactive client that uses the ' warden > ' prompt to accept commands interactively . Autocompletes commands on the prompt when the tab key is pressed . Writes the output of the command to standard out and errors to standard error . Also saves and restores the command history from a specified file . If error_on_exit flag is set then returns an integer representing the exit status ( if any ) returned by the last command that was executed successfully . Otherwise returns zero .
def start
      restore_history
      @client.connect unless @client.connected?
      comp = proc { |s|
        @commands.grep( /^#{Regexp.escape(s)}/ )
      }
      Readline.completion_append_character = " "
      Readline.completion_proc = comp
      exit_status = 0
      while line = Readline.readline('warden> ', true)
        command_info = nil
        begin
          if command_info = process_line(line)
            save_history
            STDOUT.write("#{command_info[:result]}")
          end
        rescue Warden::Protocol::ProtocolError,
          Warden::Client::ServerError,
          Warden::Repl::CommandsManager::CommandError => ce
          STDERR.write("#{ce.message}\n")
          break if @exit_on_error
        rescue Errno::EPIPE
          STDOUT.write("Reconnecting...")
          @client.disconnect
          @client.connect
          STDOUT.write("\n")
          retry
        end
        if @exit_on_error
          if command_info && command_info[:exit_status]
            exit_status = command_info[:exit_status]
          end
          break if exit_status != 0
        end
      end
      exit_status
    end
def start restore_history @client . connect unless @client . connected? comp = proc { | s | @commands . grep ( / ^ #{ Regexp . escape ( s ) } / ) } Readline . completion_append_character = " " Readline . completion_proc = comp exit_status = 0 while line = Readline . readline ( 'warden> ' , true ) command_info = nil begin if command_info = process_line ( line ) save_history STDOUT . write ( "#{command_info[:result]}" ) end rescue Warden :: Protocol :: ProtocolError , Warden :: Client :: ServerError , Warden :: Repl :: CommandsManager :: CommandError => ce STDERR . write ( "#{ce.message}\n" ) break if @exit_on_error rescue Errno :: EPIPE STDOUT . write ( "Reconnecting..." ) @client . disconnect @client . connect STDOUT . write ( "\n" ) retry end if @exit_on_error if command_info && command_info [ :exit_status ] exit_status = command_info [ :exit_status ] end break if exit_status != 0 end end exit_status end
Starts an interactive client that uses the 'warden> ' prompt to accept
commands interactively.
Starts an interactive client that uses the ' warden > ' prompt to accept commands interactively .