<commit_before>require 'chef/knife/cloudformation_base'

class Chef
  class Knife
    class CloudformationEvents < Knife

      banner 'knife cloudformation events NAME'

      include KnifeCloudformation::KnifeBase

      option(:polling,
        :short => '-p',
        :long => '--[no-]poll',
        :description => 'Poll events while stack status is "in progress"',
        :proc => lambda {|v| Chef::Config[:knife][:cloudformation][:polling] = v }
      )

      option(:attribute,
        :short => '-a ATTR',
        :long => '--attribute ATTR',
        :description => 'Attribute to print. Can be used multiple times.',
        :proc => lambda {|val|
          Chef::Config[:knife][:cloudformation][:attributes] ||= []
          Chef::Config[:knife][:cloudformation][:attributes].push(val).uniq!
        }
      )

      option(:poll_delay,
        :short => '-D secs',
        :long => '--poll-delay secs',
        :description => 'Number of seconds to pause between event poll',
        :proc => lambda {|val|
          Chef::Config[:knife][:cloudformation][:poll_delay] = val.to_i
        }
      )

      option(:all_attributes,
        :long => '--all-attributes',
        :description => 'Print all attributes'
      )

      def run
        name = name_args.first
        ui.info "Cloud Formation Events for Stack: #{ui.color(name, :bold)}\n"
        things_output(name, get_events(name), 'events')
        if(Chef::Config[:knife][:cloudformation][:poll])
          while(stack(name).in_progress?)
            sleep(Chef::Config[:knife][:cloudformation][:poll_delay] || 15)
            things_output(nil, get_events(name), 'events', :no_title)
          end
          # Extra to see completion
          things_output(nil, get_events(name), 'events', :no_title)
        end
      end

      def get_events(name)
        get_things do
          stack(name).events
        end
      end

      def default_attributes
        %w(Timestamp LogicalResourceId ResourceType ResourceStatus ResourceStatusReason)
      end
    end
  end<commit_msg>Ignore empty outputs when polling<commit_after>require 'chef/knife/cloudformation_base'

class Chef
  class Knife
    class CloudformationEvents < Knife

      banner 'knife cloudformation events NAME'

      include KnifeCloudformation::KnifeBase

      option(:polling,
        :short => '-p',
        :long => '--[no-]poll',
        :description => 'Poll events while stack status is "in progress"',
        :proc => lambda {|v| Chef::Config[:knife][:cloudformation][:polling] = v }
      )

      option(:attribute,
        :short => '-a ATTR',
        :long => '--attribute ATTR',
        :description => 'Attribute to print. Can be used multiple times.',
        :proc => lambda {|val|
          Chef::Config[:knife][:cloudformation][:attributes] ||= []
          Chef::Config[:knife][:cloudformation][:attributes].push(val).uniq!
        }
      )

      option(:poll_delay,
        :short => '-D secs',
        :long => '--poll-delay secs',
        :description => 'Number of seconds to pause between event poll',
        :proc => lambda {|val|
          Chef::Config[:knife][:cloudformation][:poll_delay] = val.to_i
        }
      )

      option(:all_attributes,
        :long => '--all-attributes',
        :description => 'Print all attributes'
      )

      def run
        name = name_args.first
        ui.info "Cloud Formation Events for Stack: #{ui.color(name, :bold)}\n"
        things_output(name, get_events(name), 'events')
        if(Chef::Config[:knife][:cloudformation][:poll])
          while(stack(name).in_progress?)
            sleep(Chef::Config[:knife][:cloudformation][:poll_delay] || 15)
            things_output(nil, get_events(name), 'events', :no_title, :ignore_empty_output)
          end
          # Extra to see completion
          things_output(nil, get_events(name), 'events', :no_title, :ignore_empty_output)
        end
      end

      def get_events(name)
        get_things do
          stack(name).events
        end
      end

      def default_attributes
        %w(Timestamp LogicalResourceId ResourceType ResourceStatus ResourceStatusReason)
      end
    end
  end
{'fraction_non_alphanumeric': 0.1336847149017729, 'fraction_numerical': 0.0009583133684714902, 'mean_word_length': 2.4362139917695473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '658514', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1198, 'n_words': 275}