lib/chef/knife/show_essentials.rb in knife-essentials-0.8.4 vs lib/chef/knife/show_essentials.rb in knife-essentials-0.8.5

- old
+ new

@@ -1,7 +1,8 @@ require 'chef_fs/knife' require 'chef_fs/file_system' +require 'chef_fs/file_system/not_found_error' class Chef class Knife remove_const(:Show) if const_defined?(:Show) && Show.name == 'Chef::Knife::Show' # override Chef's version class Show < ::ChefFS::Knife @@ -15,23 +16,32 @@ :boolean => true, :description => "Show local files instead of remote" def run # Get the matches (recursively) + error = false 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 + ui.error "#{format_path(result)}: is a directory" if pattern.exact_path + error = true else begin value = result.read - output "#{result.path_for_printing}:" + output "#{format_path(result)}:" output(format_for_display(value)) - rescue ChefFS::FileSystem::NotFoundError - ui.error "#{result.path_for_printing}: No such file or directory" + rescue ChefFS::FileSystem::OperationNotAllowedError => e + ui.error "#{format_path(e.entry)}: #{e.reason}." + error = true + rescue ChefFS::FileSystem::NotFoundError => e + ui.error "#{format_path(e.entry)}: No such file or directory" + error = true end end end + end + if error + exit 1 end end end end end