#!/usr/bin/env ruby require 'Paludis' require 'getoptlong' require 'pathname' require 'shellwords' begin require 'irb-pager' rescue LoadError STDERR.puts < 'Help', %w[\1 \2 ...] => 'Select file via index', %w[FILENAME] => 'Select file via filename', %w[\list] => 'List all files need updates', %w[\diff] => 'Displays difference of selected file', %w[\accept \yes] => 'Accepts selected file', %w[\reject \no] => 'Rejects selected file', %w[\quit \exit] => 'Quit', }) puts when *%w[d diff] raise NoSelection unless selected puts IRB::Pager::pager( pager: 'less -R') { diff selected, found[selected][0] } puts when *%w[l list] list_cfgs selected, list if selected when *%w[a accept y yes] raise NoSelection unless selected accept_cfg selected, found[selected][0] selected = nil when *%w[r reject n no] raise NoSelection unless selected reject_cfg selected, found[selected][0] selected = nil when *%w[q quit e exit] then exit(0) when 'auto-action' File.readlines '/etc/paludis/config_auto_action' do |line| action, file = line.chomp!.split( "\t", 2) file = Pathname.new file case action when *%w[a accept] accept_cfg nil, nil if file.exist? end end else m = Pathname.new x if f = found[m] selected = m else raise UsageError, "Uknown command #{x}" end end end rescue UsageError puts $! end end