Sha256: a187222ecee79591034fe8f1f65c8d9d3acbebff38942f7675dd515c0e28c2f7

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

require 'chef_fs/knife'
require 'chef_fs/file_system'

class Chef
  class Knife
    class Delete < ChefFS::Knife
      banner "knife delete [PATTERN1 ... PATTERNn]"

      common_options

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

      def run
        # Get the matches (recursively)
        pattern_args.each do |pattern|
          ChefFS::FileSystem.list(chef_fs, pattern) do |result|
            begin
              result.delete(config[:recurse])
              puts "Deleted #{result.path_for_printing}"
            rescue ChefFS::FileSystem::NotFoundError
              STDERR.puts "result.path_for_printing}: No such file or directory"
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knife-essentials-0.7.6 lib/chef/knife/delete.rb
knife-essentials-0.7.5 lib/chef/knife/delete.rb
knife-essentials-0.7.4 lib/chef/knife/delete.rb