Class: Timekeeper::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/timekeeper/runner.rb

Class Method Summary collapse

Class Method Details

.tk(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/timekeeper/runner.rb', line 5

def self.tk(args)
  options = KeeperOptions.new(args)
  if options.any?
    tk = Keeper.new
    tk.config(options.delete(:config)) if options[:config]
    
    if id = options[:remove]
      tk.delete(id)
    elsif id = options.delete(:update)
      tk.update(id, options)
    elsif id = options.delete(:track)
      tk.track(id, options[:name]) if options[:name]
    else
      tk.store(options)          
    end
    tk.close
  else
    puts options.opts
  end
end

.tv(args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/timekeeper/runner.rb', line 26

def self.tv(args)
  options = ViewerOptions.new(args)
  tv = Viewer.new
  tv.config(options.delete(:config)) if options[:config]
  records = begin
    if options[:name]
      tv.by_name(options[:name])
    elsif options[:month]
      tv.by_month(options[:month])
    else
      tv.all
    end
  end
  if output = options.delete(:output)
    Viewer.export(records, output[0], output[1])
  else
    puts records
  end
  tv.close
end