Sha256: ec112f2023ab31ad151506e9da605f205b18591317a1fb7cb540362efad498e5

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require_relative '../lib/opensource'

options = {}

LICENSES = Dir.new('../templates').map do |filename|
  File.basename(filename, '.erb') if !['.', '..'].include?(filename)
end.compact

OptionParser.new do |opts|
  opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} OPTIONS"
  opts.separator ''
  opts.separator 'Specific options:'

  opts.on('-l', '--license LICENSE', LICENSES, "LICENSE can be #{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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opensource-0.3.1 bin/opensource