<commit_before>require 'text2svg/typography'

module Text2svg
  module CLI
    Option = Struct.new(:font, :text_align, :fill)

    def start
      o = CLI::Option.new(nil, :left, :black)
      OptionParser.new.tap { |opt|
        opt.on('-f', '--font FONT', 'font file path (require)') do |arg|
          o.font = arg
        end
        opt.on('--text-align ALIGN', 'text align left,right or center (default left)', %i(left right center)) do |arg|
          o.text_align = arg
        end
        opt.on('--fill FILL', 'text fill color (default black)') do |arg|
          o.fill = arg
        end
      }.parse!(ARGV)
      text = ARGV[0] || $stdin.read
      puts Text2svg::Typography.build(text, font: o.font, text_align: o.text_align, stroke: :none, fill: o.fill)
    end
    module_function :start
  end
end
<commit_msg>Validate font option<commit_after>require 'text2svg/typography'

module Text2svg
  module CLI
    Option = Struct.new(:font, :text_align, :fill)

    def start
      o = CLI::Option.new(nil, :left, :black)
      OptionParser.new.tap { |opt|
        opt.on('-f', '--font FONT', 'font file path (require)') do |arg|
          o.font = arg
        end
        opt.on('--text-align ALIGN', 'text align left,right or center (default left)', %i(left right center)) do |arg|
          o.text_align = arg
        end
        opt.on('--fill FILL', 'text fill color (default black)') do |arg|
          o.fill = arg
        end
      }.parse!(ARGV)
      unless o.font
        raise ArgumentError, "require `--font` cli option. see --help"
      end
      text = ARGV[0] || $stdin.read
      puts Text2svg::Typography.build(text, font: o.font, text_align: o.text_align, stroke: :none, fill: o.fill)
    end
    module_function :start
  end
end

{'fraction_non_alphanumeric': 0.1403409090909091, 'fraction_numerical': 0.004545454545454545, 'mean_word_length': 2.3735632183908044, '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': '766030', 'n_tokens_mistral': 600, 'n_tokens_neox': 590, 'n_words': 169}