#!/usr/bin/env ruby-2.3
require_relative '../lib/licensee'

path = ARGV[0] || Dir.pwd

options = { detect_packages: true, detect_readme: true }
project = Licensee::GitProject.new(path, options)
file = project.matched_file

if project.license_file
  puts "License file: #{project.license_file.filename}"
  if project.license_file.attribution
    puts "Attribution: #{project.license_file.attribution}"
  end
end

if file
  puts "License: #{file.license ? file.license.meta['title'] : 'no license'}"
  puts "Confidence: #{file.confidence}%"
  puts "Method: #{file.matcher.class}"
else
  puts 'Unknown'
end
