#!/usr/bin/env ruby # encoding: UTF-8 require 'optparse' require_relative '../lib/opensource' options = {} 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::Owner.set_credentials 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.parse! begin 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