Class: Popper::CLI

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

Instance Method Summary collapse

Instance Method Details

#__print_versionObject



59
60
61
# File 'lib/popper/cli.rb', line 59

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

#initObject



50
51
52
53
54
55
# File 'lib/popper/cli.rb', line 50

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
36
37
38
# 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 {|| MailAccount.new()}
  interval = case
             when Popper.configure.global.respond_to?(:interval)
               Popper.configure.global.interval
             else
               60
             end
  while true
    accounts.each(&:run)
    sleep(interval)
  end

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


42
43
44
45
46
47
# File 'lib/popper/cli.rb', line 42

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