Sha256: d4f21f1bf8309981648031276fcb8ae06b2e439f52431446f1b9a23d6750ecce

Contents?: true

Size: 1002 Bytes

Versions: 3

Compression:

Stored size: 1002 Bytes

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require "chef/fork/commands"
require "chef/node"
require "json"

class Chef
  class Fork
    module Commands
      class Node < Noop
        def run(args=[])
          rest = order_args(args)
          case rest.first
          when "edit"
            node_edit(rest.slice(1..-1) || [])
          when "list"
            node_list(rest.slice(1..-1) || [])
          when "show"
            node_show(rest.slice(1..-1) || [])
          else
            raise(NameError.new(@args.inspect))
          end
        end

        private
        def node_edit(args=[])
          raise(NotImplementedError.new(args.inspect))
        end

        def node_list(args=[])
          raise(NotImplementedError.new(args.inspect))
        end

        def node_show(args=[])
          args.each do |node_name|
            node = Chef::Node.load(node_name)
            STDOUT.puts(JSON.pretty_generate(node.to_hash()))
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chef-fork-0.2.0 lib/chef/fork/commands/node.rb
chef-fork-0.1.4 lib/chef/fork/commands/node.rb
chef-fork-0.1.3 lib/chef/fork/commands/node.rb