Sha256: a94331a35d55adf03508760753600c0bb22c16eb2cde7e95be712567ac3ab840

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env ruby

require 'license/compatibility'

begin
  options = License::CommandLine.parse(ARGV)
rescue => e
  STDERR.puts e
  exit 2
end

status = 0

if options[:version]
  puts options[:version]

elsif options[:help]
  puts options[:help]

elsif options[:list]
  options[:list].each do |key, array|
    puts "#{key}:"
    array.each do |license|
      puts "  #{license}"
    end
    puts
  end

else

  args = ARGV
  if options[:read]
    File.read(options[:read]).split("\n").each { |line|
      unless line.empty?
        args.push(line)
      end
    }
  end

  if args.empty?
    STDERR.puts License::USAGE
    exit 2
  end

  begin
    type, args = License::CommandLine.parse_positional(args)
  rescue => e
    STDERR.puts e
    exit 2
  end

  case type
    when 'licenses'; status = License::Compatibility.check_license_list(args)
    when 'packages'; status = License::Compatibility.check_package_licence_list(args)
    else
      STDERR.puts 'Invalid arguments: they should be a list of licenses'
      STDERR.puts '  or a list of package:license couples.'
      status = 2
  end
end

exit status

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
license-compatibility-3.1.0 bin/license-compatibility
license-compatibility-3.0.0 bin/license-compatibility
license-compatibility-2.0.0 bin/license-compatibility