bin/opensource in opensource-0.6.0 vs bin/opensource in opensource-0.6.1

- old
+ new

@@ -1,24 +1,24 @@ #!/usr/bin/env ruby # encoding: UTF-8 require 'optparse' -require_relative '../lib/opensource' +require 'open_source' options = {} -OptionParser.new do |opts| +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::Owner.set_credentials + OpenSource::Owner.set_credentials exit end - opts.on('-l', '--license LICENSE', Opensource::LICENSES, "LICENSE can be #{Opensource::LICENSES.join('|')}") do |l| + 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 @@ -26,22 +26,28 @@ opts.separator '' opts.separator 'Common options:' opts.on_tail('-v', '--version', 'Print the version') do - puts Opensource::VERSION + puts OpenSource::VERSION exit end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end -end.parse! +end begin - Opensource::License.new(options).process -rescue Opensource::Error => e - # TODO: Make sure the above call raises only Opensource::Error + option_parser.parse! + if options.empty? + puts option_parser + exit 1 + 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