Class: PXMyPortal::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/pxmyportal/command.rb

Instance Method Summary collapse

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pxmyportal/command.rb', line 20

def run
  options = { company: ENV["PXMYPORTAL_COMPANY"],
              user: ENV["PXMYPORTAL_USER"],
              password: ENV["PXMYPORTAL_PASSWORD"],
              test: ENV["PXMYPORTAL_TEST"] }

  parser = OptionParser.new
  parser.on("--debug") { options[:debug] = true }
  parser.on("--cookie-jar=PATH") { warn "deprecated option" }
  parser.on("--payslips=PATH",
            "database file for previously stored payslips") { |path|
    options[:payslips_path] = path }
  parser.on("--payslip-dir=PATH") { |path| options[:payslip_dir] = path }
  parser.on("--bonus-only") { options[:bonus_only] = true }
  parser.on("--debug-http") { options[:debug_http] = true }
  parser.on("--force") { options[:force] = true }
  parser.parse!

  agent = PXMyPortal::Agent.new(**options)
  agent.save_payslips
end