Commit 11124e93 authored by Chris McKnight's avatar Chris McKnight

Add licenses command to pod cli

parent 739f4f4e
......@@ -11,6 +11,7 @@ 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
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