Skip to content
Browse files

further cleanup and tweaks on top of latest release

  • Loading branch information...
1 parent e1f61b2 commit 55cc3ede9faad9ced7ce3e9a10c2b1d86064e43f @geemus committed
Showing with 44 additions and 17 deletions.
  1. +16 −8 lib/ext/heroku/command/apps.rb
  2. +9 −6 lib/ext/heroku/command/ps.rb
  3. +19 −3 lib/ext/heroku/helpers.rb
View
24 lib/ext/heroku/command/apps.rb
@@ -103,9 +103,13 @@ def create
stack = extract_option('--stack', 'aspen-mri-1.8.6')
timeout = extract_option('--timeout', 30).to_i
name = args.shift.downcase.strip rescue nil
- style_action("creating #{name}")
+ if name
+ style_action("Creating #{name}")
+ else
+ style_action("Creating")
+ end
info = heroku.create_app(name, {:stack => stack})
- name = info["name"]
+ name = info["name"]
begin
if info["create_status"] == "creating"
Timeout::timeout(timeout) do
@@ -117,10 +121,11 @@ def create
end
end
hputs("done, stack is #{info["stack"]}")
+ hputs
(options[:addons] || "").split(",").each do |addon|
addon.strip!
- style_action("adding #{addon} to #{name}")
+ style_action("Adding #{addon} to #{name}")
heroku.install_addon(name, addon)
hputs("done")
end
@@ -130,8 +135,8 @@ def create
end
style_object({
- :git_url => info["git_url"],
- :web_url => info["web_url"]
+ "Git URL" => info["git_url"],
+ "Web URL" => info["web_url"]
})
rescue Timeout::Error
error("Timed Out! Check heroku status for known issues.")
@@ -150,9 +155,10 @@ def rename
newname = args.shift.downcase.strip rescue ''
raise(Heroku::Command::CommandFailed, "Must specify a new name.") if newname == ''
- style_action("renaming #{app} to #{newname}")
+ style_action("Renaming #{app} to #{newname}")
heroku.update(app, :name => newname)
hputs("done")
+ hputs
info = heroku.info(newname)
style_object({
@@ -182,6 +188,8 @@ def open
info = heroku.info(app)
url = info[:web_url]
style_action("opening #{url}")
+ hputs("done")
+ hputs
Launchy.open url
end
@@ -197,12 +205,11 @@ def destroy
raise Heroku::Command::CommandFailed.new("Usage: heroku apps:destroy --app APP")
end
- action("destroying #{app} (including all add-ons)")
-
heroku.info(app) # fail fast if no access or doesn't exist
message = "WARNING: Potentially Destructive Action\nThis command will destroy #{app} (including all add-ons)."
if confirm_command(app, message)
+ style_action("destroying #{app} (including all add-ons)")
heroku.destroy(app)
if remotes = git_remotes(Dir.pwd)
remotes.each do |remote_name, remote_app|
@@ -211,6 +218,7 @@ def destroy
end
end
hputs("done")
+ hputs
end
end
View
15 lib/ext/heroku/command/ps.rb
@@ -93,19 +93,20 @@ def index
def restart
opts = case args.first
when NilClass then
- style_action("Restarting processes")
+ style_action("Restarting Processes")
{}
when /.+\..+/
ps = args.first
- style_action("Restarting #{ps} process")
+ style_action("Restarting #{ps} Process")
{ :ps => ps }
else
type = args.first
- style_action("Restarting #{type} processes")
+ style_action("Restarting #{type} Processes")
{ :type => type }
end
heroku.ps_restart(app, opts)
hputs("done")
+ hputs
end
alias_command "restart", "ps:restart"
@@ -128,10 +129,11 @@ def scale
error "Usage: heroku ps:scale web=2 worker+1" if changes.empty?
changes.each do |process, amount|
- style_action("scaling #{process} processes")
+ style_action("Scaling #{process} Processes")
amount.gsub!("=", "")
new_qty = heroku.ps_scale(app, :type => process, :qty => amount)
hputs("done, now running #{new_qty}")
+ hputs
end
end
@@ -147,11 +149,11 @@ def stop
opt =
if (args.first =~ /.+\..+/)
ps = args.first
- style_action("stopping #{ps} process")
+ style_action("Stopping #{ps} Process")
{:ps => ps}
elsif args.first
type = args.first
- style_action("stopping #{type} processes")
+ style_action("Stopping #{type} Processes")
{:type => type}
else
error "Usage: heroku ps:stop PROCESS"
@@ -159,6 +161,7 @@ def stop
heroku.ps_stop(app, opt)
hputs("done")
+ hputs
end
alias_command "stop", "ps:stop"
View
22 lib/ext/heroku/helpers.rb
@@ -2,11 +2,12 @@ module Heroku
module Helpers
def style_warning(message)
- hputs("~~~ #{message}")
+ hputs("~~ #{message}")
end
def style_action(action)
- hprint("=== #{action}")
+ hputs
+ hprint("++ #{action}... ")
end
def style_header(header)
@@ -16,7 +17,7 @@ def style_header(header)
end
def style_info(info)
- hputs("=== #{info}")
+ hputs("-- #{info}")
end
def style_object(object)
@@ -52,5 +53,20 @@ def style_object(object)
end
end
+ # monkey-patches
+
+ def create_git_remote(remote, url)
+ return if git('remote').split("\n").include?(remote)
+ return unless File.exists?(".git")
+ git "remote add #{remote} #{url}"
+ display "Git remote #{remote} added"
+ hputs
+ end
+
+ def format_with_bang(message)
+ return '' if message.to_s.strip == ""
+ "!! " + message.split("\n").join("\n!! ")
+ end
+
end
end

0 comments on commit 55cc3ed

Please sign in to comment.
Something went wrong with that request. Please try again.