Sha256: 8ea7ef9271dfe31c5e9fbea3ef2d97deef7e02e8af7a1ccf77c2df9df87ec76a

Contents?: true

Size: 1005 Bytes

Versions: 1

Compression:

Stored size: 1005 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 = optparse.order(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(rest.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

1 entries across 1 versions & 1 rubygems

Version Path
chef-fork-0.1.2 lib/chef/fork/commands/node.rb