#!/usr/bin/env ruby # encoding: UTF-8 require 'optparse' require 'open_source' options = {} option_parser = OptionParser.new do |opts| opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} OPTIONS" opts.separator '' opts.separator 'Specific options:' opts.on('-s', '--setup', 'Setup user credentials in ~/.osrc file') do |s| OpenSource.setup_owner_credentails exit end opts.on('-l', '--license LICENSE', OpenSource::LICENSES, "LICENSE can be #{OpenSource::LICENSES.join(', ')}") do |l| options[:license] = l end opts.on('-a', '--append README', 'Append LICENSE content to README file') do |a| options[:append] = a end opts.separator '' opts.separator 'Common options:' opts.on_tail('-v', '--version', 'Print the version') do puts OpenSource::VERSION exit end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end end begin option_parser.parse! if options.empty? puts option_parser exit 0 end OpenSource::License.new(options).process rescue OpenSource::Error => e # TODO: Make sure the above call raises only OpenSource::Error puts "Error: #{e.message}" exit 1 end