From 113d3a59eaa7547433434d155fc1e60aa7c2094c Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 11 Oct 2012 00:42:46 -0700 Subject: code cleanup. better support for nested configs and templates. --- lib/leap_cli/commands/list.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/leap_cli/commands/list.rb') diff --git a/lib/leap_cli/commands/list.rb b/lib/leap_cli/commands/list.rb index 166ed2a..0f1c96e 100644 --- a/lib/leap_cli/commands/list.rb +++ b/lib/leap_cli/commands/list.rb @@ -1,16 +1,16 @@ module LeapCli module Commands - def self.print_config_table(type, config_list) + def self.print_config_table(type, object_list) style = {:border_x => '-', :border_y => ':', :border_i => '-', :width => 60} if type == :services t = table do self.style = style self.headings = ['SERVICE', 'NODES'] - list = config_list.keys.sort + list = object_list.keys.sort list.each do |name| - add_row [name, config_list[name].nodes.keys.join(', ')] + add_row [name, object_list[name].node_list.keys.join(', ')] add_separator unless name == list.last end end @@ -20,9 +20,9 @@ module LeapCli t = table do self.style = style self.headings = ['TAG', 'NODES'] - list = config_list.keys.sort + list = object_list.keys.sort list.each do |name| - add_row [name, config_list[name].nodes.keys.join(', ')] + add_row [name, object_list[name].node_list.keys.join(', ')] add_separator unless name == list.last end end @@ -32,9 +32,11 @@ module LeapCli t = table do self.style = style self.headings = ['NODE', 'SERVICES', 'TAGS'] - list = config_list.keys.sort + list = object_list.keys.sort list.each do |name| - add_row [name, config_list[name].services.to_a.join(', '), config_list[name].tags.to_a.join(', ')] + services = object_list[name]['services'] || [] + tags = object_list[name]['tags'] || [] + add_row [name, services.to_a.join(', '), tags.to_a.join(', ')] add_separator unless name == list.last end end -- cgit v1.2.3