Sha256: 9ce5178624ac4b180dc1bce6f532d39eda1a0e1fd02e4c5e51cf4466cfa388bb

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 Bytes

Contents

#!/usr/bin/env ruby

require 'burglar'
require 'mercenary'
require 'cymbal'
require 'yaml'

def add_common_opts(c)
  c.option :config, '-c FILE', '--config FILE', 'Config file to load'
  c.option :begin, '-b DATE', '--begin DATE', 'Beginning of date range'
  c.option :end, '-e DATE', '--end DATE', 'End of date range'
end

def load_config(file)
  file ||= '~/.burglar.yml'
  file = File.expand_path file
  Cymbal.symbolize YAML.safe_load(File.read(file))
end

Mercenary.program(:burglar) do |p|
  p.version Burglar::VERSION
  p.description 'Load data from banks'
  p.syntax 'burglar [options]'

  add_common_opts(p)

  p.action do |_, options|
    options[:end] ||= Date.today
    options[:begin] ||= options[:end] - 30
    config = load_config(options[:config]).merge(options)
    puts Burglar.new(config).transactions
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
burglar-0.0.2 bin/burglar