#!/usr/bin/env ruby require 'dmtool' require 'optparse' def opts_from_cli options = {} opt_parser = OptionParser.new do |opts| opts.program_name = File.basename(__FILE__) opts.banner = "#{opts.program_name} [options]" opts.on('-r', '--raw', 'Display raw results (ignores +/- modifiers)') { options[:raw] = true } opts.on('-v', '--version', 'Print version information') do puts "#{File.basename(__FILE__)} #{DMTool::VERSION}" exit true end opts.on('-h', '--help', 'Display this screen') do puts opts exit true end end begin opt_parser.parse! rescue OptionParser::InvalidOption => e puts e.message exit false end options end def results_from(options) parser = DMTool::Parser.new input = ARGV.join(' ') command = options[:raw] ? 'raw' : 'roll' parser.parse("#{command} #{input}") end puts results_from(opts_from_cli)