Sha256: 0710f7061d55896274f231011ab53b11be03d1287dd02302e4501be7557d848c
Contents?: true
Size: 1015 Bytes
Versions: 1
Compression:
Stored size: 1015 Bytes
Contents
#!/usr/bin/env ruby require 'burglar' require 'mercenary' require 'cymbal' require 'yaml' require 'date' 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 def date_parse_or_default(string, default) return default unless string Date.parse(string) 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_parse_or_default(options[:end], Date.today) options[:begin] = date_parse_or_default(options[:begin], options[:end]) 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.3 | bin/burglar |