Sha256: 4135a9fe806ce079e8c6a0a9252f9098449356dc424c42be9c785ad158428c25

Contents?: true

Size: 866 Bytes

Versions: 3

Compression:

Stored size: 866 Bytes

Contents

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

class Chef
  class Knife
    class Show < ChefFS::Knife
      banner "show [PATTERN1 ... PATTERNn]"

      def run
        # Get the matches (recursively)
        pattern_args.each do |pattern|
          ChefFS::FileSystem.list(chef_fs, pattern) do |result|
            if result.dir?
              STDERR.puts "#{format_path(result.path)}: is a directory" if pattern.exact_path
            else
              begin
                value = result.read
                puts "#{format_path(result.path)}:"
                output(format_for_display(result.read))
              rescue ChefFS::FileSystem::NotFoundError
                STDERR.puts "#{format_path(result.path)}: No such file or directory" if pattern.exact_path
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knife-essentials-0.3 lib/chef/knife/show.rb
knife-essentials-0.2.1 lib/chef/knife/show.rb
knife-essentials-0.2 lib/chef/knife/show.rb