forked from hamilton2br/rally-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask
executable file
·76 lines (64 loc) · 1.75 KB
/
task
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
#!/usr/bin/env ruby
require 'csv'
require 'rally_rest_api'
require 'ostruct'
require 'optparse'
require 'yaml'
require 'pp'
options = OpenStruct.new
options.pdffile = "output.pdf"
options.csvfile = "output.csv"
options.csvoutput = false
options.pdfouput = false
options.iteration = ""
options.user = nil
options.password = nil
opts = OptionParser.new
opts.banner = "Usage: status [options] TASKID [...]"
opts.on('-d','--defined','set task state to "defined"') do
options.state = 'Defined'
end
opts.on('-p','--in-progress','set task state to "in progress"') do
options.state = 'In-Progress'
end
opts.on('-c','--completed','set task state to "completed"') do
options.state='Completed'
end
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_tail( '-h', '--help', 'Displays this screen' ) do
puts opts
exit
end
opts.parse!(ARGV)
if ARGV.length < 1
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 iteration
rally = RallyRestAPI.new(:username => rally_user, :password => rally_pass)
ARGV.each do |arg|
res = rally.find( :task ) { equal :formatted_i_d, arg }
task = res.results.first
if options.state then
task.update(:state => options.state)
puts "#{task.formatted_i_d} state set to '#{options.state}'"
else
puts "#{task.formatted_i_d} state is '#{task.state}' (#{task.name})"
end
end