Sha256: 90d84accbe95205c1a4574fde57a27dd060126438cc9fcf403ed5ce923e72ad3

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'chef_fs/knife'
require 'chef_fs/command_line'

class Chef
  class Knife
    remove_const(:Diff) if const_defined?(:Diff) && Diff.name == 'Chef::Knife::Diff' # override Chef's version
    class Diff < ::ChefFS::Knife
      ChefFS = ::ChefFS
      banner "knife diff PATTERNS"

      common_options

      option :recurse,
        :long => '--[no-]recurse',
        :boolean => true,
        :default => true,
        :description => "List directories recursively."

      option :name_only,
        :long => '--name-only',
        :boolean => true,
        :description => "Only show names of modified files."

      option :name_status,
        :long => '--name-status',
        :boolean => true,
        :description => "Only show names and statuses of modified files: Added, Deleted, Modified, and Type Changed."

      def run
        if config[:name_only]
          output_mode = :name_only
        end
        if config[:name_status]
          output_mode = :name_status
        end
        patterns = pattern_args_from(name_args.length > 0 ? name_args : [ "" ])

        # Get the matches (recursively)
        patterns.each do |pattern|
          ChefFS::CommandLine.diff_print(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, output_mode, proc { |entry| format_path(entry.path) } ) do |diff|
            stdout.print diff
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife-essentials-0.8.4 lib/chef/knife/diff_essentials.rb