<commit_before># encoding: utf-8
module Filegen
  # Commandline from end
  class Runner
    private

    attr_reader :argv

    public

    # Create runner
    # @param [Array] argv
    #  Commandline arguments
    # @param [IO] stdin
    #  Stdin
    # @param [IO] stdout
    #  Stdout
    # @param [IO] stderr
    #  Stderr
    # @param [Kernel] kernel
    #  Kernel class
    def initialize(argv, stdin = $stdin, stdout = $stdout, stderr = $stderr, kernel = Kernel)
      @argv, $stdin, $stdout, Ui.logger, @kernel = argv, stdin, stdout, stderr, kernel
    end

    # Execute runner
    def execute!
      begin
        options   = Options.new(argv)

        generator = ErbGenerator.new(Data.new(options.data_sources))
        generator.compile(options.source, options.destination)

        exitstatus = 0
      rescue RuntimeError => e
        Filegen::Ui.error e.message
        exitstatus = 1
      end

      @kernel.exit(exitstatus)<commit_msg>Handle interrupt<commit_after># encoding: utf-8
module Filegen
  # Commandline from end
  class Runner
    private

    attr_reader :argv

    public

    # Create runner
    # @param [Array] argv
    #  Commandline arguments
    # @param [IO] stdin
    #  Stdin
    # @param [IO] stdout
    #  Stdout
    # @param [IO] stderr
    #  Stderr
    # @param [Kernel] kernel
    #  Kernel class
    def initialize(argv, stdin = $stdin, stdout = $stdout, stderr = $stderr, kernel = Kernel)
      @argv, $stdin, $stdout, Ui.logger, @kernel = argv, stdin, stdout, stderr, kernel
    end

    # Execute runner
    def execute!
      begin
        options   = Options.new(argv)

        generator = ErbGenerator.new(Data.new(options.data_sources))
        generator.compile(options.source, options.destination)

        exitstatus = 0
      rescue RuntimeError => e
        Filegen::Ui.error e.message
        exitstatus = 1
      rescue Interrupt => e
        Filegen::Ui.warning 'You told me to stop command execution.'
        exitstatus = 2
      end

      @kernel.exit(exitstatus)
{'fraction_non_alphanumeric': 0.09610645638245441, 'fraction_numerical': 0.0034499753573188764, 'mean_word_length': 2.344316309719934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2932828', 'n_tokens_mistral': 649, 'n_tokens_neox': 622, 'n_words': 175}