[PATCH v5 02/15] contrib: related: add option parsing
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/related/git-related | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/contrib/related/git-related b/contrib/related/git-related
index 4f31482..6f18cc8 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -3,6 +3,8 @@
# This script finds people that might be interested in a patch
# usage: git related <file>
+require 'optparse'
+
$since = '5-years-ago'
$min_percent = 10
@@ -10,6 +12,21 @@ def fmt_person(name, email)
name ? '%s <%s>' % [name, email] : email
end
+begin
+ OptionParser.new do |opts|
+ opts.program_name = 'git related'
+ opts.banner = 'usage: git related [options] <file>'
+
+ opts.on('-p', '--min-percent N', Integer, 'Minium percentage of role participation') do |v|
+ $min_percent = v
+ end
+ opts.on('-d', '--since DATE', 'How far back to search for relevant commits') do |v|
+ $since = v
+ end
+ end.parse!
+rescue OptionParser::InvalidOption
+end
+
class Commit
attr_reader :persons
--
1.8.3.rc2.542.g24820ba