Sha256: cec794d2a3513a6f30761861edbccd357656b704d084d050f65936b9cc613917
Contents?: true
Size: 1.98 KB
Versions: 10
Compression:
Stored size: 1.98 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) rx_strict = directories[0..-2]. map { |d| "#{Regexp.quote(d)}\\w*" }. join("/") rx_strict = Regexp.new("#{rx_strict}/#{Regexp.quote(directories.last)}$") candidates_strict = [] 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 if name =~ rx_strict candidates_strict << srcdir end end if candidates.size > 1 && candidates_strict.size == 1 candidates = candidates_strict 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
10 entries across 10 versions & 1 rubygems