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
|
# File 'lib/time_cop/runner.rb', line 7
def self.invoke
options_parser = OptionParser.new(ARGV)
options = options_parser.parse
interactive_hash = {}
if (options[:interactive])
cli = HighLine.new
username = cli.ask('Harvest Username: ')
password = cli.ask('Harvest Password: ') { |q| q.echo = false }
interactive_hash[:hours_per_week] = cli.ask('Hours per week? ') { |q| q.default = 32 }.to_i
cli.choose do ||
.prompt = 'Which Quarter? '
.choice(:Q1) { interactive_hash[:date] = Date.new(Date.today.year, 1, 1)}
.choice(:Q2) { interactive_hash[:date] = Date.new(Date.today.year, 4, 1)}
.choice(:Q3) { interactive_hash[:date] = Date.new(Date.today.year, 7, 1)}
.choice(:Q4) { interactive_hash[:date] = Date.new(Date.today.year, 10, 1)}
end
end
accountability_options = {
username: (username.nil? ? options[:username] : username),
password: (password.nil? ? options[:password] : password),
email: options[:email]
}
accountability_options = interactive_hash.merge(accountability_options)
accountability = Accountability.new(
accountability_options
)
accountability.print_report
rescue Harvest::AuthenticationFailed
puts 'Unable to authenticate to Harvest. Check username/password.'
rescue Harvest::HTTPError => e
puts 'Harvest API Error'
puts e.to_s
end
|