Commit 2019ee33 authored by Chris McKnight's avatar Chris McKnight

Move license info into podfile-info command

parent 11124e93
......@@ -11,7 +11,6 @@ module Pod
require 'cocoapods/command/help'
require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/lib'
require 'cocoapods/command/licenses'
require 'cocoapods/command/list'
require 'cocoapods/command/outdated'
require 'cocoapods/command/podfile_info'
......
module Pod
class Command
class Licenses < Command
self.summary = 'Show licenses of installed pods'
self.description = <<-DESC
Shows the licenses of installed pods
DESC
def initialize(argv)
super
end
def run
verify_podfile_exists!
verify_lockfile_exists!
lockfile = config.lockfile
pods = lockfile.pod_names
licenses = []
deps = lockfile.dependencies.map{|d| d.name}
pods = (deps + pods).uniq
pods.each do |pod_name|
spec = (Pod::SourcesManager.search_by_name(pod_name).first rescue nil)
license = "Unknown"
if spec
specification = spec.specification
license = specification.license[:type] || "Unknown"
end
licenses << [pod_name, license]
end
if licenses.empty?
UI.puts "No pods found.".yellow
else
UI.section "Licenses:" do
licenses.each do |(name, license)|
UI.puts "#{name}: #{license}"
end
end
end
end
end
end
end
......@@ -14,13 +14,15 @@ module Pod
def self.options
[
["--all", "Show information about all Pods with dependencies that are used in a project"],
["--md", "Output information in Markdown format"]
["--md", "Output information in Markdown format"],
["--license", "Additionally output license type"]
].concat(super)
end
def initialize(argv)
@info_all = argv.flag?('all')
@info_in_md = argv.flag?('md')
@info_license = argv.flag?('license')
@podfile_path = argv.shift_argument
super
end
......@@ -64,6 +66,9 @@ module Pod
if spec
info = {}
keys.each { |k| info[k] = spec.specification.send(k) }
if @info_license
info[:license] ||= spec.specification.license[:type]
end
pods_info << info
else
......@@ -78,9 +83,9 @@ module Pod
pods.each do |pod|
if in_md
UI.puts "* [#{pod[:name]}](#{pod[:homepage]}) - #{pod[:summary]}"
UI.puts ["* [#{pod[:name]}](#{pod[:homepage]}) - #{pod[:summary]}", pod[:license]].compact.join(' - ')
else
UI.puts "- #{pod[:name]} - #{pod[:summary]}"
UI.puts ["- #{pod[:name]} - #{pod[:summary]}", pod[:license]].compact.join(' - ')
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment