Sha256: 567ee3f841a4bd92ee9cf25c5ecb423f12011828cffdc9fccf1ba30386776fcf

Contents?: true

Size: 835 Bytes

Versions: 4

Compression:

Stored size: 835 Bytes

Contents

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

class Chef
  class Knife
    class Delete < ChefFS::Knife
      banner "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

4 entries across 4 versions & 1 rubygems

Version Path
knife-essentials-0.7.3 lib/chef/knife/delete.rb
knife-essentials-0.7.2 lib/chef/knife/delete.rb
knife-essentials-0.7.1 lib/chef/knife/delete.rb
knife-essentials-0.7 lib/chef/knife/delete.rb