]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
added support for disabling nodes
authorelijah <elijah@riseup.net>
Mon, 27 May 2013 20:59:02 +0000 (13:59 -0700)
committerelijah <elijah@riseup.net>
Mon, 27 May 2013 20:59:02 +0000 (13:59 -0700)
lib/leap_cli/commands/list.rb
lib/leap_cli/config/manager.rb

index 4ff23678345d5e8069a042024d0f6c047e84c801..7e803d40993169c3062ba73531d828de9eeb3e09 100644 (file)
@@ -13,8 +13,12 @@ module LeapCli; module Commands
   arg_name 'FILTER', :optional => true
   command :list do |c|
     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|
       puts
+      if options['disabled']
+        manager.load(:include_disabled => true) # reload, with disabled nodes
+      end
       if options['print']
         print_node_properties(manager.filter(args), options['print'])
       else
@@ -39,9 +43,9 @@ module LeapCli; module Commands
       node.evaluate
       value = properties.collect{|prop|
         if node[prop].nil?
-          "[null]"
+          "null"
         elsif node[prop] == ""
-          "[empty]"
+          "empty"
         else
           node[prop]
         end
index 0d145418d8e22a867bd21986e7e9a873082be310..1f81166a6a36934296fc073098e393d505c01965 100644 (file)
@@ -17,7 +17,7 @@ module LeapCli
       #
       # load .json configuration files
       #
-      def load
+      def load(options = {})
         @provider_dir = Path.provider
 
         # load base
@@ -47,6 +47,18 @@ module LeapCli
           @nodes[name] = apply_inheritance(node)
         end
 
+        # remove disabled nodes
+        unless options[:include_disabled]
+          @nodes.select! do |name, node|
+            if node.enabled
+              true
+            else
+              log 2, :skipping, "disabled node #{name}."
+              false
+            end
+          end
+        end
+
         # validate
         validate_provider(@provider)
       end