Class: Popper::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/popper/cli.rb

Instance Method Summary collapse

Instance Method Details

#__print_versionObject



56
57
58
# File 'lib/popper/cli.rb', line 56

def __print_version
  puts "Popper version:#{Popper::VERSION}"
end

#initObject



47
48
49
50
51
52
# File 'lib/popper/cli.rb', line 47

def init
  Popper::Init.run(options)
  rescue => e
    puts e
    puts e.backtrace
end

#popObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/popper/cli.rb', line 12

def pop
  if(options[:daemon])
    Popper.init_logger(options)
    Process.daemon
    open(options[:pidfile] || "/var/run/popper.pid" , 'w') {|f| f << Process.pid}
  else
    Popper.init_logger(options, true)
  end

  Popper.load_config(options)

  accounts = Popper.configure.accounts.map do ||
    MailAccount.new()
  end.compact

  while true
    accounts.each(&:run)
    sleep(Popper.configure.interval)
  end

  rescue => e
    Popper.log.fatal(e)
    Popper.log.fatal(e.backtrace)
end


39
40
41
42
43
44
# File 'lib/popper/cli.rb', line 39

def print
  Popper.load_config(options)
  Popper.configure.accounts.each do ||
    print_config()
  end
end