Skip to content

Commit

Permalink
Adding --no-color option to "server pricing"
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Gredeskoul committed May 10, 2014
1 parent 2ef9c8b commit 1c97358
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/chef/knife/joyent_server_pricing.rb
Expand Up @@ -14,21 +14,27 @@ class JoyentServerPricing < Knife

option :show_zones,
:short => '-z',
:long => '--show-zones',
:description => 'Print list of on-demand zones sorted by price',
:long => '--show-zone-flavors',
:description => 'Print aggregated list of zone flavors sorted by price',
:proc => Proc.new { |key| Chef::Config[:knife][:show_zones] = key }

banner 'knife joyent server pricing [-r <reserve-pricing.yml> ] [ -z ] '
option :no_color,
:long => '--no-color',
:description => 'Disable color when printing',
:proc => Proc.new { |key| Chef::Config[:knife][:no_color] = true }

banner 'knife joyent server pricing [-r your-reserve-pricing.yml -z --no-color ...] '

def run
flavors = []
self.connection.servers.each do |s|
flavor = s.package || 'unknown'
flavors << flavor
end
reporter = Joyent::Cloud::Pricing::Reporter.new(Chef::Config[:knife][:reserve_pricing], flavors)
reporter.print_zone_list = Chef::Config[:knife][:show_zones]
puts reporter.render
config = Chef::Config[:knife]
reporter = Joyent::Cloud::Pricing::Reporter.new(config[:reserve_pricing], flavors)
reporter.print_zone_list = config[:show_zones]
puts reporter.render(:disable_color => config[:no_color])
rescue => e
output_error(e)
end
Expand Down

0 comments on commit 1c97358

Please sign in to comment.