-
Notifications
You must be signed in to change notification settings - Fork 41
/
cli.rb
37 lines (32 loc) · 833 Bytes
/
cli.rb
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
module Planet
class CLI
def initialize
parse_options
run
end
private
def parse_options
@options = Trollop.options do
banner "Planet fetcher, updates the feeds"
opt :interval, "Dispatch update every n minutes", type: :integer
opt :logfile, "Path to logfile", type: :string
opt :verbosity, "Verbosity (debug, info, warn, error)", type: :string
end
end
def run
Planet.logger.info "Entering mainloop"
loop do
fetch_new_entries
Planet.logger.info { "Sleeping for #{Planet.config.interval} minutes" }
sleep Planet.config.interval*60
end
end
def fetch_new_entries
Planet.logger.info "Fetching new entries"
fetcher.run
end
def fetcher
@fetcher ||= Fetcher.new
end
end
end