diff options
author | elijah <elijah@riseup.net> | 2014-06-27 17:19:51 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-06-27 17:19:51 -0700 |
commit | 09a82209f3a40e75caf966ba41b17da1a9ced146 (patch) | |
tree | 586cfdff7b8d42736ab6559c917b9d2fce4b130c /lib/leap_cli/commands | |
parent | 6da0270db08f734f2d586a0fc957875e86485549 (diff) |
leap list improvements: lazy evaluation; don't bomb on ConfigError; remove requirements.rb
Diffstat (limited to 'lib/leap_cli/commands')
-rw-r--r-- | lib/leap_cli/commands/list.rb | 9 | ||||
-rw-r--r-- | lib/leap_cli/commands/pre.rb | 18 |
2 files changed, 5 insertions, 22 deletions
diff --git a/lib/leap_cli/commands/list.rb b/lib/leap_cli/commands/list.rb index 5b84113..be9163b 100644 --- a/lib/leap_cli/commands/list.rb +++ b/lib/leap_cli/commands/list.rb @@ -15,15 +15,15 @@ module LeapCli; module Commands c.flag 'print', :desc => 'What attributes to print (optional)' c.switch 'disabled', :desc => 'Include disabled nodes in the list.', :negatable => false c.action do |global_options,options,args| + # don't rely on default manager(), because we want to pass custom options to load() + manager = LeapCli::Config::Manager.new if global_options[:color] colors = ['cyan', 'white'] else colors = [nil, nil] end puts - if options['disabled'] - manager.load(:include_disabled => true) # reload, with disabled nodes - end + manager.load(:include_disabled => options['disabled'], :continue_on_error => true) if options['print'] print_node_properties(manager.filter(args), options['print']) else @@ -45,7 +45,6 @@ module LeapCli; module Commands properties = properties.split(',') max_width = nodes.keys.inject(0) {|max,i| [i.size,max].max} nodes.each_node do |node| - node.evaluate value = properties.collect{|prop| if node[prop].nil? "null" @@ -68,7 +67,7 @@ module LeapCli; module Commands @colors = colors end def run - tags = @tag_list.keys.sort + tags = @tag_list.keys.select{|tag| tag !~ /^_/}.sort # sorted list of tags, excluding _partials max_width = [20, (tags+[@heading]).inject(0) {|max,i| [i.size,max].max}].max table :border => false do row :color => @colors[0] do diff --git a/lib/leap_cli/commands/pre.rb b/lib/leap_cli/commands/pre.rb index 4b62b5b..835eada 100644 --- a/lib/leap_cli/commands/pre.rb +++ b/lib/leap_cli/commands/pre.rb @@ -32,11 +32,6 @@ module LeapCli; module Commands # set verbosity # LeapCli.log_level = global[:verbose].to_i - if LeapCli.log_level > 1 - ENV['GLI_DEBUG'] = "true" - else - ENV['GLI_DEBUG'] = "false" - end # # load Leapfile @@ -68,18 +63,7 @@ module LeapCli; module Commands log_version LeapCli.log_in_color = global[:color] - # - # load all the nodes everything - # - manager - - # - # check requirements - # - REQUIREMENTS.each do |key| - assert_config! key - end - + true end private |