lib/pandan/command/query.rb in pandan-0.0.1 vs lib/pandan/command/query.rb in pandan-0.0.3

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'pandan/command' require 'pandan/parser' require 'pandan/graph' require 'pandan/xcworkspace' @@ -11,10 +13,11 @@ def self.options [ ['--xcworkspace=path/to/workspace', 'If not set, Pandan will try to find a workspace'], ['--reverse', 'If set, pandan will output the targets that depend on the argument'], + ['--implicit-dependencies', 'If set, pandan will look up for linker flags in all build configurations'], ['--comma-separated', 'If set, Pandan outputs a comma-separated list instead of multiple lines'], ['--filter=expression', 'If set, pandan will select all targets whose name match the regular expression'] ].concat(super) end @@ -25,12 +28,14 @@ def initialize(argv) @target = argv.shift_argument @xcworkspace = argv.option('xcworkspace') @xcworkspace ||= XCWorkspace.find_workspace @reverse = argv.flag?('reverse') + @implicit_deps = argv.flag?('implicit-dependencies') @comma_separated = argv.flag?('comma-separated') @filter = argv.option('filter') + @filter ||= '.*' # Match everything super end def validate! super @@ -39,17 +44,19 @@ help! 'Could not find the workspace. Try setting it manually using the --xcworkspace option.' unless @xcworkspace end def run parser = Parser.new(@xcworkspace, @filter) - targets = parser.all_targets graph = Graph.new(@reverse) + targets = parser.all_targets graph.add_target_info(targets) + if @implicit_deps + ld_flags_info = parser.other_linker_flags + graph.add_other_ld_flags_info(ld_flags_info) + end deps = graph.resolve_dependencies(@target).map(&:name) - unless @filter.nil? - deps.select! do |dep| - dep.name.include? @filter - end + deps.select! do |dep| + dep =~ /#{@filter}/ end if @comma_separated puts deps.join ',' else