#!/usr/bin/env ruby lib_dir = %(#{File.expand_path "#{__FILE__}/../.."}/lib) $LOAD_PATH << lib_dir unless $LOAD_PATH.include? lib_dir require 'code_stats' require 'optparse' options = {} parser = OptionParser.new do |opts| opts.banner = <<-TEXT Language-agnostic Code Statistics Usage: $ code_stats /projects/wordpress /projects/drupal $ code_stats /projects/* $ code_stats /projects/wordpress --except JavaScript --skip /tmp/ TEXT opts.on("--except LANG", "Analyze all languages except specified.") do |lang| (options[:except] ||= []) << lang.to_sym end opts.on("--only LANG", "Analyze only specified language(es).") do |lang| (options[:only] ||= []) << lang.to_sym end opts.on( "--specs REGEX", "Specify paths that should be threated as specs/tests (default #{CodeStats::Project::DEFAUL_SPEC_FILTER.source})." ) do |re| options[:spec_filter] = Regexp.new(re) end opts.on( "--skip REGEX", "Specify paths that should be skipped (default #{CodeStats::Project::DEFAUL_SKIP_FILTER.source})." ) do |re| options[:skip_filter] = Regexp.new(re) end end parser.parse! if ARGV.empty? puts parser.banner else CodeStats.analyze_and_report *(ARGV + [options]) end