Module: Frecli::Cli

Defined in:
lib/frecli/cli.rb

Class Method Summary collapse

Class Method Details

.log(description = '') ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/frecli/cli.rb', line 40

def self.log(description = '')
  timer = Frecli.timer_current

  unless timer
    puts 'No timer running.'
    return
  end

  if Frecli.timer_log(timer, description)
    puts "Logged #{timer.project.name} (#{timer.formatted_time})."
    puts %Q("#{description}") unless description.empty?
  else
    puts 'Could not log timer.'
  end
end

.pauseObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/frecli/cli.rb', line 25

def self.pause
  timer = Frecli.timer_current

  unless timer
    puts 'No timer running.'
    return
  end

  if Frecli.timer_pause(timer)
    puts "Paused #{timer.project.name} (#{timer.formatted_time})."
  else
    puts 'Could not pause timer.'
  end
end

.statusObject



5
6
7
8
9
10
11
12
13
# File 'lib/frecli/cli.rb', line 5

def self.status
  timer = Frecli.timer_current

  if timer
    puts "Timer running on #{timer.project.name} (#{timer.formatted_time})."
  else
    puts "No timer running."
  end
end

.time(project_query) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/frecli/cli.rb', line 15

def self.time(project_query)
  project = FuzzyMatch
    .new(Frecli.projects, read: :name)
    .find(project_query)

  timer = Frecli.timer_start(project)

  puts "Now timing #{project.name} (#{timer.formatted_time})."
end