#!/usr/bin/env ruby require 'pathname' root = Pathname.new(__FILE__).realpath.parent.parent $:.unshift root.join('lib') if $0 == __FILE__ require 'optparse' require 'oddb2xml' def help < false, :adr => false, :nonpharma => false, :compress_ext => nil, :format => :xml, :tag_suffix => nil, :debug => false, :ean14 => false, } parser.on('-a v', '--append v', /^nonpharma$/) {|v| opts[:nonpharma] = true } parser.on('-c v', '--compress v', /^tar\.gz|zip$/){|v| opts[:compress_ext] = v } parser.on('-f v', '--format v', /^xml|dat$/) {|v| opts[:format] = v.intern } parser.on('-o v', '--option v', /^fi$/) {|v| opts[:fi] = true } parser.on('-i v', '--include v', /^ean14$/) {|v| opts[:ean14] = true } parser.on('-t v', '--tag-suffix v', /^[A-z0-9]*$/i) {|v| opts[:tag_suffix] = v.upcase } parser.on('-x v', '--context v', /^addr(ess)*$/i){|v| opts[:address] = true } #parser.on('--debug') {|v| opts[:debug] = true } parser.on_tail('-h', '--help') { puts help; exit } args = ARGV.dup begin parser.parse!(args) rescue OptionParser::MissingArgument, OptionParser::InvalidArgument, OptionParser::InvalidOption puts help exit end ui = Oddb2xml::Cli.new(opts) begin if opts[:format] == :xml opts[:ean14] = true # force end #puts opts if opts[:debug] if RUBY_VERSION.to_f < 1.9 message = <<-MES Once you find some time, please upgrade your Ruby to 1.9.3 ;) then you will not see anymore warnings MES warn message end ui.run rescue Interrupt puts exit end