From 6bdb238453bd4c4303f8466e9f5c37e95b90da75 Mon Sep 17 00:00:00 2001 From: Mark Fine Date: Fri, 1 Mar 2013 11:58:40 -0800 Subject: [PATCH 1/2] sync up console approach with rake approach. --- lib/heroku/command/run.rb | 53 +++------------------------------------ 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/lib/heroku/command/run.rb b/lib/heroku/command/run.rb index 765fb7338..1299f2640 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 rake` 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 From fac786847093c06604d68aa750f419957717c0d5 Mon Sep 17 00:00:00 2001 From: Mark Fine Date: Fri, 1 Mar 2013 12:03:09 -0800 Subject: [PATCH 2/2] ugh, it's console, not rake. --- lib/heroku/command/run.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/heroku/command/run.rb b/lib/heroku/command/run.rb index 1299f2640..eb10b2444 100644 --- a/lib/heroku/command/run.rb +++ b/lib/heroku/command/run.rb @@ -91,7 +91,7 @@ def rake # >> # def console - deprecate("`heroku #{current_command}` has been deprecated. Please use `heroku run rake` instead.") + deprecate("`heroku #{current_command}` has been deprecated. Please use `heroku run console` instead.") command = "console #{args.join(' ')}" run_attached(command) end