Sha256: 8d23629e3c7499017132fa5131ce097a5e3476735507a835bf05869d4fae0af5

Contents?: true

Size: 1.88 KB

Versions: 5

Compression:

Stored size: 1.88 KB

Contents

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

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

      common_options

      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 upload everything in this directory, type \"knife upload .\"")
          exit 1
        end

        error = false
        pattern_args.each do |pattern|
          if ChefFS::FileSystem.copy_to(pattern, local_fs, chef_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

5 entries across 5 versions & 1 rubygems

Version Path
knife-essentials-1.1.1 lib/chef/knife/upload_essentials.rb
knife-essentials-1.1 lib/chef/knife/upload_essentials.rb
knife-essentials-1.0.0 lib/chef/knife/upload_essentials.rb
knife-essentials-1.0.0.beta5 lib/chef/knife/upload_essentials.rb
knife-essentials-1.0.0.beta4 lib/chef/knife/upload_essentials.rb