bin/gh_compare in gh_compare-0.1.3 vs bin/gh_compare in gh_compare-0.1.4
- old
+ new
@@ -1,7 +1,22 @@
#!/usr/bin/env ruby
-raise ArgumentError, "wrong number of arguments (given #{ARGV.length}, expected 2)" if ARGV.length != 2
-
require_relative '../lib/gh_compare'
-compare = GhCompare::CommitCompare.new
-puts compare.compare_url(ARGV[0], ARGV[1])
+require 'optparse'
+options = {}
+
+OptionParser.new do |opt|
+ opt.on('--n=NUM', Integer) { |v| options[:num] = v }
+ opt.on('--d==V,V', Array) { |v| options[:commits] = v }
+
+ opt.parse!(ARGV)
+end
+
+if options[:num]
+ compare = GhCompare::CommitCompare.new
+ puts compare.compare_before(options[:num])
+end
+
+if options[:commits]
+ compare = GhCompare::CommitCompare.new
+ puts compare.compare_url(options[:commits][0], options[:commits][1])
+end