<commit_before>require 'optparse'
require 'glam'

module Glam
  class CLI

    def self.run
      new.run
    end

    def initialize
      @options = {
        indent_size: 2,
      }
    end

    def run
      @parser = OptionParser.new do |o|
        o.on "-i", "--indent [INDENT]", Integer do |indent_size|
          @options[:indent_size] = indent_size
        end
      end

      @parser.banner = "glam [options] file"

      @parser.on_tail "-h", "--help", "Show help" do
        $stderr.puts @parser
        exit 1
      end

      @parser.parse!

      glam = Glam::Glamorizer.new(@options)

      html = if ARGV[0]
        file = File.expand_path(ARGV[0])
        if File.exists?(file)
          File.read(file)
        else
          $stderr.puts "#{file} does not exist"
          exit 2
        end
      else
        STDIN.read
      end

      puts glam.glamorize(html)
    end
  end
end<commit_msg>Improved command-line help output, added an option to print the version<commit_after>require 'optparse'
require 'glam'

module Glam
  class CLI

    def self.run
      new.run
    end

    def initialize
      @options = {
        indent_size: 2,
      }
    end

    def run
      @parser = OptionParser.new do |o|
        o.on "-i", "--indent [INDENT]", "How many spaces to indent at each level", Integer do |indent_size|
          @options[:indent_size] = indent_size
        end
      end

      @parser.banner = "glam #{Glam::VERSION}\n\nUsage: glam [options] file"

      @parser.on_tail "-h", "--help", "Show help" do
        $stderr.puts @parser
        exit 1
      end

      @parser.on_tail "-v", "--version", "Print the version" do
        $stderr.puts Glam::VERSION
        exit 2
      end

      @parser.parse!

      glam = Glam::Glamorizer.new(@options)

      html = if ARGV[0]
        file = File.expand_path(ARGV[0])
        if File.exists?(file)
          File.read(file)
        else
          $stderr.puts "#{file} does not exist"
          exit 3
        end
      else
        STDIN.read
      end

      puts glam.glamorize(html)
    end
  end
end
{'fraction_non_alphanumeric': 0.10919540229885058, 'fraction_numerical': 0.005268199233716475, 'mean_word_length': 1.7200520833333333, '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': '6294312', 'n_tokens_mistral': 705, 'n_tokens_neox': 672, 'n_words': 187}