Method: Autoproj::CLI::Query#query_source_packages

Defined in:
lib/autoproj/cli/query.rb

#query_source_packages(query_string, selected_packages, format: "$NAME", search_all: false, only_present: false) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/autoproj/cli/query.rb', line 77

def query_source_packages(query_string, selected_packages, format: "$NAME", search_all: false, only_present: false)
    if query_string.empty?
        query = SourcePackageQuery.all
    else
        query = SourcePackageQuery.parse_query(query_string.first)
    end

    if search_all
        packages = ws.manifest.each_package_definition.to_a
    else
        packages = selected_packages.map do |pkg_name|
            ws.manifest.find_package_definition(pkg_name)
        end
    end

    if only_present
        packages = packages.find_all do |pkg|
            File.directory?(pkg.autobuild.srcdir)
        end
    end

    matches = find_all_matches(query, packages)

    matches.each do |priority, pkg_def|
        puts format_source_package(format, priority, pkg_def)
    end
end