bin/cloud-terminate in poolparty-1.2.2 vs bin/cloud-terminate in poolparty-1.3.1
- old
+ new
@@ -1,28 +1,35 @@
#!/usr/bin/env ruby
-$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
+$:.unshift(File.dirname(__FILE__) + "/../lib")
require "poolparty"
-require "poolpartycl"
-o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
- opts.on('-n name', '--name name', 'Terminate the cloud of this name') { |c| optioner.cloudname c }
- opts.on('-y', '--yes', 'Terminate the cloud without prompt') { optioner.yes true }
-end
+require 'git-style-binary/command'
-o.loaded_clouds.each do |cld|
- cld.nodes(:status => "running").each do |inst|
- msg = <<-EOM
-Shutting down #{inst.instance_id}
-Are you sure? (Y/N)
- EOM
-
- if o.yes?
- puts "Shutting down #{inst.instance_id}"
- cld.terminate_instance!(:instance_id => inst.instance_id)
- else
- if are_you_sure?(msg)
- puts "Shutting down #{inst.instance_id}"
- cld.terminate_instance!(:instance_id => inst.instance_id)
+GitStyleBinary.command do
+ banner <<-EOS
+Usage: #{$0} #{all_options_string} COMMAND [ARGS]
+
+ terminate the cloud
+EOS
+
+ short_desc "terminate the cloud"
+
+ opt :yes, "Answer yes to the are you sure question", :type => :boolean, :default => false
+
+ run do |command|
+ @loaded_clouds.each do |cld|
+ msg = [
+ "Shutting down #{cld.name} cloud",
+ "Are you sure? (Y/N)"
+ ]
+
+ o = command[:yes] || are_you_sure?(msg)
+ if o
+ vputs "Shutting down cloud"
+ cld.terminate!
+ else
+
end
- end
+
+ end
end
end
\ No newline at end of file