forked from hamilton2br/rally-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskpair
executable file
·90 lines (75 loc) · 1.77 KB
/
taskpair
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env ruby
require 'csv'
require 'rally_rest_api'
require 'ostruct'
require 'optparse'
require 'yaml'
require 'gruff'
options = OpenStruct.new
options.csvoutput = false
options.pdfouput = false
options.iteration = ""
options.user = nil
options.password = nil
opts = OptionParser.new
opts.banner = "Usage: taskpair [options] TASKID username , username ..."
opts.on('-U username','--user=username','Provides a Rally User') do |user|
options.user = user
end
opts.on('-P password','--password=password','Provides a Rally Password') do |pass|
options.password = pass
end
opts.on('-r','--remove','Removes rally users from the task') do |user|
options.action='remove'
end
opts.on('-a','--add','Adds rally users to the task') do |user|
options.action='add'
end
opts.on_tail( '-h', '--help', 'Displays this screen' ) do
puts opts
exit
end
opts.parse!(ARGV)
obj_name = ARGV.shift
if !obj_name then
puts opts
exit
end
begin
config = YAML.load_file("#{Dir.home}/.rallyutils")
rescue
if !options.user and !options.password then
puts opts
puts "\nERROR: #{Dir.home}/.rallyutils not found and no user/password provided"
exit
end
end
rally_user=options.user || config["user"]
rally_pass=options.password || config["password"]
#Queries iteratio
rally = RallyRestAPI.new(:username => rally_user, :password => rally_pass)
res = rally.find( :task ) { equal :formatted_i_d , obj_name }
task = res.first
pair = []
if task.pair then
pair = task.pair.split(',')
end
if options.action == 'add' then
ARGV.each do |user|
if !pair.include?(user) then
pair.push(user)
end
end
end
if options.action == 'remove' then
ARGV.each do |user|
if pair.include?(user) then
pair.delete(user)
end
end
end
if options.action then
task.update(:pair => pair.join(','))
else
puts pair
end