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
# File lib/skipper/repl.rb, line 55 def print_help puts %q[Skipper Help help - this message servers - list the servers that commands will be executed on exit - bye, bye] end
print_servers()
click to toggle source
# File lib/skipper/repl.rb, line 63 def print_servers puts servers.to_s end
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