class FlogCLI
def self.parse_options args = ARGV, extra_options = {}
def self.parse_options args = ARGV, extra_options = {} option = { :quiet => false, :continue => false, :parser => RubyParser, }.merge extra_options OptionParser.new do |opts| opts.separator "Standard options:" opts.on("-a", "--all", "Display all flog results, not top 60%.") do option[:all] = true end opts.on("-b", "--blame", "Include blame information for methods.") do option[:blame] = true end opts.on("-c", "--continue", "Continue despite syntax errors.") do option[:continue] = true end opts.on("-d", "--details", "Show method details.") do option[:details] = true end opts.on("-g", "--group", "Group and sort by class.") do option[:group] = true end opts.on("-h", "--help", "Show this message.") do puts opts exit end opts.on("-I dir1,dir2,dir3", Array, "Add to LOAD_PATH.") do |dirs| dirs.each do |dir| $: << dir end end opts.on("-m", "--methods-only", "Skip code outside of methods.") do option[:methods] = true end opts.on("-q", "--quiet", "Don't show parse errors.") do option[:quiet] = true end opts.on("-e", "--extended", "Put file:line on a separate line (for rubymine & friends).") do option[:extended] = true end opts.on("-s", "--score", "Display total score only.") do option[:score] = true end opts.on("-tN", "--threshold=N", Integer, "Set the report cutoff threshold (def: 60%).") do |n| option[:threshold] = n / 100.0 end opts.on("-v", "--verbose", "Display progress during processing.") do option[:verbose] = true end next if self.plugins.empty? opts.separator "Plugin options:" extra = self.method_scores.grep(/parse_options/) - %w(parse_options) extra.sort.each do |msg| self.send msg, opts, option end end.parse! Array(args) option end