#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../lib/ohloh_scm' # This is a simple command line tool which parses CVS and Subversion logs. # It is not used by the main Ohloh system. # # I use it primarily to help debug Ohloh behavior. It's a convenient way # to turn an enormously long CVS log into something readable. module OhlohScm::Parsers class CommandLine attr_accessor :paths, :writer def initialize(args=[]) args = args.clone # Because shift is destructive set_option(args.shift) while args.first =~ /^-/ self.paths = args end def help puts < self.writer end else parser.parse STDIN, :writer => self.writer end end def subcommand=(s) if @subcommand STDERR.puts "Error: Multiple commands specified." exit 1 else @subcommand=s end end def subcommand @subcommand end def set_option(option) case option when '--cvs' self.subcommand = :cvs when '--git' self.subcommand = :git when '--svn' self.subcommand = :svn when '--svn-xml' self.subcommand = :svn_xml when '--hg' self.subcommand = :hg when '--bzr' self.subcommand = :bzr when '--bzr-xml' self.subcommand = :bzr_xml when '-h', '--human' self.writer = HumanWriter.new(STDOUT) when '-x', '--xml' self.writer = XmlWriter.new(STDOUT) when '-?', '--help' self.subcommand = :help else STDERR.puts "Type 'ohlog -?' for usage." exit 1 end end def run! self.subcommand ||= :summary if self.respond_to?(self.subcommand) self.send(self.subcommand) else STDERR.puts "Type 'ohlog -?' for usage." exit 1 end end end CommandLine.new(ARGV).run! end