class HeroShell
Public Class Methods
new(herokuApp, forceCommandsSync)
click to toggle source
# File lib/heroshell.rb, line 5 def initialize(herokuApp, forceCommandsSync) @forceCommandSync = forceCommandsSync @app = herokuApp end
Public Instance Methods
init_completion()
click to toggle source
# File lib/heroshell.rb, line 10 def init_completion() autocompleted_commands = HerokuCommandsCache.get_commands(@forceCommandSync) Readline.completion_append_character = " " Readline.completer_word_break_characters = "" Readline.completion_proc = proc { |s| autocompleted_commands.grep(/^#{Regexp.escape(s)}/) } end
run()
click to toggle source
# File lib/heroshell.rb, line 19 def run() init_completion() while buf = Readline.readline("(#{Rainbow(@app).red})> ", false) buf = buf.strip() if buf.empty? next end if buf.start_with?("switch ") switchTo = buf.split(" ")[1] if switchTo @app = switchTo Readline::HISTORY.push(buf) else $stderr.puts "use: \"switch <herokuApp>\" to switch to other app" end else command, arguments = buf.split(/\s+/, 2) res = system("heroku #{command} -a #{@app} #{arguments}") if res Readline::HISTORY.push(buf) else $stderr.puts "Command \"#{command}\" returned non-zero status." end end end puts '' end