Sha256: 40134395422cb7d3e4dd5ff3045beec5765639007c6e98aac90550920300d211
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
require 'optparse' require 'ostruct' module Ims class Parser class << self def parse(options) OpenStruct.new.tap do |args| args.contacts = [] args.text = nil args.attachment = nil args.verbose = false opt_parser(args).parse!(options) end end private def opt_parser(args) OptionParser.new do |opts| opts.banner = "Usage: ims [options]" opts.separator "" opts.separator "Specific options:" opts.on("-t", "--to x,y,z", Array, "Deliver message TO these contacts") do |contacts| args.contacts = contacts end opts.on("-m", "--message [MESSAGE]", String, "The MESSAGE to deliver") do |mesg| if File.exists?(mesg) args.attachment = File.expand_path(mesg) else args.text = mesg end end opts.separator "" opts.separator "Common options:" opts.on("-v", "--version", "Show version") do puts "ims v#{Imsg::VERSION}" exit end opts.on("-h", "--help", "Prints this help") do puts opts exit end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ims-0.8.2 | lib/ims/parser.rb |
ims-0.8.1 | lib/ims/parser.rb |
ims-0.8.0 | lib/ims/parser.rb |