Sha256: e19c4a395e896dd720004205dd9f58289e3fdbed62f0cb8e0fb240e059254cb2

Contents?: true

Size: 1.91 KB

Versions: 8

Compression:

Stored size: 1.91 KB

Contents

require 'chef_fs/knife'

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

      deps do
        require 'chef_fs/command_line'
      end

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

      option :purge,
        :long => '--[no-]purge',
        :boolean => true,
        :default => false,
        :description => "Delete matching local files and directories that do not exist remotely."

      option :force,
        :long => '--[no-]force',
        :boolean => true,
        :default => false,
        :description => "Force upload of files even if they match (quicker and harmless, but doesn't print out what it changed)"

      option :dry_run,
        :long => '--dry-run',
        :short => '-n',
        :boolean => true,
        :default => false,
        :description => "Don't take action, only print what would happen"

      option :diff,
        :long => '--[no-]diff',
        :boolean => true,
        :default => true,
        :description => 'Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff'

      def run
        if name_args.length == 0
          show_usage
          ui.fatal("Must specify at least one argument.  If you want to download everything in this directory, type \"knife download .\"")
          exit 1
        end

        error = false
        pattern_args.each do |pattern|
          if ChefFS::FileSystem.copy_to(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry) })
            error = true
          end
        end
        if error
          exit 1
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
knife-essentials-1.5.2 lib/chef/knife/download_essentials.rb
knife-essentials-1.5.1 lib/chef/knife/download_essentials.rb
knife-essentials-1.5 lib/chef/knife/download_essentials.rb
knife-essentials-1.4 lib/chef/knife/download_essentials.rb
knife-essentials-1.3.2 lib/chef/knife/download_essentials.rb
knife-essentials-1.3 lib/chef/knife/download_essentials.rb
knife-essentials-1.2.1 lib/chef/knife/download_essentials.rb
knife-essentials-1.2 lib/chef/knife/download_essentials.rb