<commit_before># encoding: utf-8

module GithubCLI
  # This class determines editor to use to open the output.
  class Editor

    def initialize(options={})
    end

    def editor
      editors = [ ENV['GHC_EDITOR'], ENV['VISUAL'], ENV['EDITOR'], 'vi' ]
      editor = GithubCLI.config['editor']
      editor ||= editors.find { |e| !e.nil? && !e.empty? }
    end

    def open(name)
      if editor
        command = "#{editor} #{name}"
        success = system(command)
        GithubCLI.ui.info "Could not run '#{command}'" unless success
      else
        GithubCLI.info("To open output, set $EDITOR or $VISUL")
      end
    end

  end # Editor
end # GithubCLI<commit_msg>Change to seek config file editor first, add proper exit codes.<commit_after># encoding: utf-8

module GithubCLI
  # This class determines editor to use to open the output.
  class Editor

    attr_accessor :filename

    def initialize(filename, options={})
      @filename = filename
    end

    def editor
      editors = [ ENV['GCLI_EDITOR'], ENV['VISUAL'], ENV['EDITOR'], 'vi' ]
      editors.unshift(GithubCLI.config['core.editor'])
      editors.compact.uniq.find { |editor| System.command? editor }
    end

    def open(name=nil)
      if editor
        command = "#{editor} #{name}"
        success = system(command)
        GithubCLI.ui.info "Could not run '#{command}'" unless success
        exit success
      else
        GithubCLI.info("To open output, set $EDITOR or $VISUL")
        exit 1
      end
    end

  end # Editor
end # GithubCLI
{'fraction_non_alphanumeric': 0.11646063760572543, 'fraction_numerical': 0.001951854261548471, 'mean_word_length': 2.6188235294117646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1325600', 'n_tokens_mistral': 492, 'n_tokens_neox': 479, 'n_words': 146}