class Skipper::Repl

Attributes

cli[RW]
options[RW]
runner[RW]
servers[RW]

Public Class Methods

new(options, cli) click to toggle source
# File lib/skipper/repl.rb, line 7
def initialize(options, cli)
  @options = options
  @cli = cli

  if options.servers?
    @servers = Skipper::Servers::Basic.new(options)
  else
    @servers = Skipper::Servers::EC2.new(options)
  end

  @runner = Skipper::Runner.new(@servers, options, cli)
end

Public Instance Methods

run() click to toggle source
# File lib/skipper/repl.rb, line 20
def run
  loop do
    begin
      repl
    rescue SSHKit::Runner::ExecuteError => e
      cli.say e, :red
    rescue Interrupt
      puts ''
    end
  end
end

Private Instance Methods

handle_command(command) click to toggle source
# File lib/skipper/repl.rb, line 40
def handle_command(command)
  case command
  when 'h'
  when 'help'
    print_help
  when 'servers'
    print_servers
  when 'quit'
  when 'exit'
    quit
  else
    runner.run(command)
  end
end
print_help() click to toggle source
print_servers() click to toggle source
quit() click to toggle source
# File lib/skipper/repl.rb, line 67
def quit
  puts 'See ya!'
  exit 0
end
repl() click to toggle source
# File lib/skipper/repl.rb, line 34
def repl
  while command = Readline.readline("> ", true)
    handle_command(command.chomp)
  end
end