lib/chef/knife/show_essentials.rb in knife-essentials-0.9.8 vs lib/chef/knife/show_essentials.rb in knife-essentials-1.0.0.beta1

- old
+ new

@@ -17,27 +17,34 @@ :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 "#{format_path(result)}: is a directory" if pattern.exact_path + entry_values = parallelize(pattern_args, :flatten => true) do |pattern| + parallelize(ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern)) do |entry| + if entry.dir? + ui.error "#{format_path(entry)}: is a directory" if pattern.exact_path error = true + nil else begin - value = result.read - output "#{format_path(result)}:" - output(format_for_display(value)) + [entry, entry.read] rescue ChefFS::FileSystem::OperationNotAllowedError => e ui.error "#{format_path(e.entry)}: #{e.reason}." error = true + nil rescue ChefFS::FileSystem::NotFoundError => e ui.error "#{format_path(e.entry)}: No such file or directory" error = true + nil end end + end + end + entry_values.each do |entry, value| + if entry + output "#{format_path(entry)}:" + output(format_for_display(value)) end end if error exit 1 end