<commit_before>require 'optparse'
require 'matter_compiler/composer'

module MatterCompiler
  
  class CLI
    
    attr_reader :command

    def self.start
      cli = CLI.new
      options = cli.parse_options!(ARGV)
      cli.runCommand(ARGV, options)
    end

    def runCommand(args, options)
      command = :compose if args.first.nil? || @command.nil?
      command = @command if @command

      if command == :compose && args.first.nil? && (options[:format].nil? || options[:format] == :unknown_ast)

        print options[:format] ? "invalid value of" : "missing"
        print " '--format option'\n\n"

        CLI::help
        exit 1
        end

      case command
      when :compose
        Composer.compose(args.first, options[:format])
      when :version
        puts MatterCompiler::VERSION
      else
        CLI::help
      end
          
    end

    def parse_options!(args)
      @command = nil
      options = {}
      options_parser = OptionParser.new do |opts|
        opts.on('-f', '--format (yaml|json)') do |format|
          options[:format] = Composer.parse_format(format)
          @command = :compose
        end

        opts.on('-v', '--version') do
          @command = :version
        end

        opts.on( '-h', '--help') do
          @command = :help
        end
      end

      options_parser.parse!
      options

    rescue OptionParser::InvalidOption => e
      puts e
      CLI::help
      exit 1
    end

    def self.help
        puts "Usage: matter_compiler [options] [<ast file>]"
        puts "\nCompose an API blueprint from its AST."
        puts "If no <ast file> is specified 'matter_compiler' will listen on stdin."
        
        puts "\nOptions:\n\n"
        puts "\t-f, --format (yaml|json)        Set the AST media-type format of the input"
        puts "\t-h, --help                      Show this help"
        puts "\t-v, --version                   Show version"
        puts "\n"
    end

  end

end
<commit_msg>Use . notation for referencing methods<commit_after>require 'optparse'
require 'matter_compiler/composer'

module MatterCompiler
  
  class CLI
    
    attr_reader :command

    def self.start
      cli = CLI.new
      options = cli.parse_options!(ARGV)
      cli.runCommand(ARGV, options)
    end

    def runCommand(args, options)
      command = :compose if args.first.nil? || @command.nil?
      command = @command if @command

      if command == :compose && args.first.nil? && (options[:format].nil? || options[:format] == :unknown_ast)

        print options[:format] ? "invalid value of" : "missing"
        print " '--format option'\n\n"

        CLI.help
        exit 1
        end

      case command
      when :compose
        Composer.compose(args.first, options[:format])
      when :version
        puts MatterCompiler::VERSION
      else
        CLI.help
      end
          
    end

    def parse_options!(args)
      @command = nil
      options = {}
      options_parser = OptionParser.new do |opts|
        opts.on('-f', '--format (yaml|json)') do |format|
          options[:format] = Composer.parse_format(format)
          @command = :compose
        end

        opts.on('-v', '--version') do
          @command = :version
        end

        opts.on( '-h', '--help') do
          @command = :help
        end
      end

      options_parser.parse!
      options

    rescue OptionParser::InvalidOption => e
      puts e
      CLI.help
      exit 1
    end

    def self.help
        puts "Usage: matter_compiler [options] [<ast file>]"
        puts "\nCompose an API blueprint from its AST."
        puts "If no <ast file> is specified 'matter_compiler' will listen on stdin."
        
        puts "\nOptions:\n\n"
        puts "\t-f, --format (yaml|json)        Set the AST media-type format of the input"
        puts "\t-h, --help                      Show this help"
        puts "\t-v, --version                   Show version"
        puts "\n"
    end

  end

end

{'fraction_non_alphanumeric': 0.1120603015075377, 'fraction_numerical': 0.0010050251256281408, 'mean_word_length': 1.780027932960894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '6313670', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1175, 'n_words': 338}