<commit_before># encoding: utf-8
STDOUT.sync
require 'colored'
require 'highline'
require 'steps/spinner'

module Steps
  class Output

    @spinner = Steps::Spinner.new
    @task_depth = 0
    @stacked_result = false
    @highline = HighLine.new

    def self.step(desc, options)
      self.start_to desc
      begin
        smessage = yield
        smessage = "✔" unless smessage.is_a? String
        self.success smessage
      rescue Exception => e
          message = e.message.empty? ? "X" : e.message

          self.error(message)
          if options[:vital]
            raise "X"
          end
      end
    end

    def self.start_to message
      lead_str = ""
      if @spinner.running?
        @spinner.stop
        if @stacked_result
          lead_str = "\r#{`tput el`}"
        else
          lead_str = "\n"
        end
      end

      if @task_depth > 0
        message = lead_str + ("|   " * (@task_depth - 1)) + "├── " + message
      end

      print "#{message}".yellow + "   "
      @spinner.start
      @task_depth += 1
      @stacked_result = false
    end
<commit_msg>only continue to bubble exceptions of not a top level step<commit_after># encoding: utf-8
STDOUT.sync
require 'colored'
require 'highline'
require 'steps/spinner'

module Steps
  class Output

    @spinner = Steps::Spinner.new
    @task_depth = 0
    @stacked_result = false
    @highline = HighLine.new

    def self.step(desc, options)
      self.start_to desc
      begin
        smessage = yield
        smessage = "✔" unless smessage.is_a? String
        self.success smessage
      rescue Exception => e
          message = e.message.empty? ? "X" : e.message

          if options[:vital]
            if @task_depth > 1
              self.error(message)
              raise "X"
            else
              self.error_and_exit(message)
            end
          end
      end
    end

    def self.start_to message
      lead_str = ""
      if @spinner.running?
        @spinner.stop
        if @stacked_result
          lead_str = "\r#{`tput el`}"
        else
          lead_str = "\n"
        end
      end

      if @task_depth > 0
        message = lead_str + ("|   " * (@task_depth - 1)) + "├── " + message
      end

      print "#{message}".yellow + "   "
      @spinner.start
      @task_depth += 1
      @stacked_result = false
    end

{'fraction_non_alphanumeric': 0.1025531914893617, 'fraction_numerical': 0.004680851063829788, 'mean_word_length': 1.7116493656286045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '2054005', 'n_tokens_mistral': 757, 'n_tokens_neox': 737, 'n_words': 190}