Sha256: 945e2333321931cd82b48e1410f7aeedee1b9d72c64c3c1a84a05573b306305c

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

#!/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_credentials
    exit
  end

  opts.on('-l', '--license LICENSE', OpenSource::SUPPORTED_LICENSES, "LICENSE can be #{OpenSource::SUPPORTED_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
    OpenSource.logger.info(OpenSource::VERSION)
    exit
  end

  opts.on_tail('-h', '--help', 'Show this message') do
    OpenSource.logger.info(opts)
    exit
  end
end

begin
  option_parser.parse!
  if options.empty?
    OpenSource.logger.info(option_parser)
    exit 0
  end

  OpenSource::License::Generator.new(options).generate
rescue OpenSource::Error => e
  # TODO: Make sure the above call raises only OpenSource::Error
  OpenSource.logger.fatal("Error: #{e.message}")
  exit 1
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opensource-1.1.2 exe/opensource
opensource-1.0.0 exe/opensource