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
|
# File 'lib/commands/start.rb', line 3
def self.included(thor)
thor.class_eval do
desc "start [NAME]", "Start new timer"
def start(name)
log = Log.find_by(name: name)
if !log
say "#{name} not found", :red
exit
end
if log.active?
say "#{name} already active", :red
exit
end
if log.start!
started_at = time_display(Time.now)
say "#{name} started at #{started_at}", :green
else
say "#{name} failed to start", :red
end
end
end
end
|