#! /usr/bin/env ruby require 'autoproj/cli/main' require 'autoproj/cli/locate' argv = Autoproj::CLI.basic_setup if argv.include?('--help') || argv.include?('help') puts "Usage:" puts " alog [package]" puts puts "Shows log available for the given package and allows to select and display one" exit 0 end Autoproj.report(silent: true) do cli = Autoproj::CLI::Locate.new arg = argv.first || Dir.pwd if File.directory?(arg) arg = "#{File.expand_path(arg)}/" end log_files = cli.logs_of(arg, log: nil) if log_files.size == 1 logfile = log_files.first puts File.read(logfile) elsif log_files.size > 1 begin logfile = cli.select_log_file(log_files) puts File.read(logfile) rescue Interrupt end elsif log_files.empty? raise "no logs found for #{string}" end end