Sha256: 02bd066b68b12408c777ac42335e91bb5548dcd8e6c54571026b985ec95d398d

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

#! /usr/bin/env ruby

require 'autoproj'
require 'autoproj/cmdline'

Autoproj.silent = true
root_dir  = Autoproj::CmdLine.initialize_root_directory
selection = Autoproj::CmdLine.initialize_and_load(ARGV)
if selection.empty?
    puts root_dir
    exit 0
elsif selection.size > 1
    STDERR.puts Autoproj.console.color("more than one name given on the command line", :red)
    exit 1
end
selection = selection.first

selection_rx = Regexp.new(Regexp.quote(selection))
candidates = []
Autoproj.manifest.each_package do |pkg|
    name = pkg.name
    next if !Autoproj.manifest.package_enabled?(name)

    srcdir = Autobuild::Package[name].srcdir
    if name == selection
        puts srcdir
        exit(0)
    elsif name =~ selection_rx
        candidates << srcdir
    end
end

if candidates.empty?
    # Try harder. Match directory prefixes
    directories = selection.split('/')
    rx = directories.
        map { |d| "#{Regexp.quote(d)}\\w*" }.
        join("/")
    rx = Regexp.new(rx)

    Autoproj.manifest.each_package do |pkg|
        name = pkg.name
        next if !Autoproj.manifest.package_enabled?(name)

        srcdir = Autobuild::Package[name].srcdir
        if name =~ rx
            candidates << srcdir
        end
    end

end

if candidates.empty?
    STDERR.puts Autoproj.console.color("cannot find #{selection} in the current autoproj installation", :bold, :red)
    exit 1
elsif candidates.size > 1
    STDERR.puts Autoproj.console.color("multiple packages match #{selection} in the current autoproj installation: #{candidates.join(", ")}", :bold, :red)
    exit 1
else
    puts candidates.first
    exit(0)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
autoproj-1.7.3.b1 bin/autolocate
autoproj-1.7.2 bin/autolocate
autoproj-1.7.1 bin/autolocate
autoproj-1.7.0 bin/autolocate