Sha256: 3357f8dbe77562847f85f16ae642a836bdd3d6495b0a6a0d3e87eb6c71983b43

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

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

class Chef
  class Knife
    remove_const(:Show) if const_defined?(:Show) && Show.name == 'Chef::Knife::Show' # override Chef's version
    class Show < ::ChefFS::Knife
      ChefFS = ::ChefFS
      banner "knife show [PATTERN1 ... PATTERNn]"

      common_options

      option :local,
        :long => '--local',
        :boolean => true,
        :description => "Show local files instead of remote"

      def run
        # Get the matches (recursively)
        pattern_args.each do |pattern|
          ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern) do |result|
            if result.dir?
              ui.error "#{result.path_for_printing}: is a directory" if pattern.exact_path
            else
              begin
                value = result.read
                output "#{result.path_for_printing}:"
                output(format_for_display(value))
              rescue ChefFS::FileSystem::NotFoundError
                ui.error "#{result.path_for_printing}: No such file or directory"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knife-essentials-0.8.4 lib/chef/knife/show_essentials.rb
knife-essentials-0.8.3 lib/chef/knife/show_essentials.rb
knife-essentials-0.8.2 lib/chef/knife/show_essentials.rb