diff --git a/lib/heroku/command/run.rb b/lib/heroku/command/run.rb index 765fb7338..eb10b2444 100644 --- a/lib/heroku/command/run.rb +++ b/lib/heroku/command/run.rb @@ -91,12 +91,11 @@ def rake # >> # def console - puts "`heroku #{current_command}` has been removed. Please use: `heroku run` instead." - puts "For more information, please see:" - puts " * https://devcenter.heroku.com/articles/one-off-dynos" - puts " * https://devcenter.heroku.com/articles/rails3#console" - puts " * https://devcenter.heroku.com/articles/console-bamboo" + deprecate("`heroku #{current_command}` has been deprecated. Please use `heroku run console` instead.") + command = "console #{args.join(' ')}" + run_attached(command) end + alias_command "console", "run:console" protected @@ -133,48 +132,4 @@ def rendezvous_session(rendezvous_url, &on_connect) set_buffer(true) end end - - def console_history_dir - FileUtils.mkdir_p(path = "#{home_directory}/.heroku/console_history") - path - end - - def console_session(app) - heroku.console(app) do |console| - console_history_read(app) - - display "Ruby console for #{app}.#{heroku.host}" - while cmd = Readline.readline('>> ') - unless cmd.nil? || cmd.strip.empty? - console_history_add(app, cmd) - break if cmd.downcase.strip == 'exit' - display console.run(cmd) - end - end - end - end - - def console_history_file(app) - "#{console_history_dir}/#{app}" - end - - def console_history_read(app) - history = File.read(console_history_file(app)).split("\n") - if history.size > 50 - history = history[(history.size - 51),(history.size - 1)] - File.open(console_history_file(app), "w") { |f| f.puts history.join("\n") } - end - history.each { |cmd| Readline::HISTORY.push(cmd) } - rescue Errno::ENOENT - rescue Exception => ex - display "Error reading your console history: #{ex.message}" - if confirm("Would you like to clear it? (y/N):") - FileUtils.rm(console_history_file(app)) rescue nil - end - end - - def console_history_add(app, cmd) - Readline::HISTORY.push(cmd) - File.open(console_history_file(app), "a") { |f| f.puts cmd + "\n" } - end end