#!/usr/bin/env io_static # # Small Io script for getting ebuild atom information. # fetoms.io # # Ebuild := Object clone do ( portagepath := "/usr/portage/" ebuilds := List clone listEbuilds := method(pname, ex := try (ebuilds = Directory with(pname) fileNames select(containsSeq(".ebuild"))) ex catch(Exception, writeln(pname, " directory doesn't exist."))) readEbuild := method(ebuild, File with(ebuild) openForReading contents) getAtom := method(atoms, package, abspath := portagepath .. package self listEbuilds(abspath) ebuilds foreach(e, writeln("-- ", e, " --") atoms foreach(atom, write(atom ," => ") v := readEbuild(abspath .. "/" .. e) split("\n#{atom}=\"" interpolate) ex := try (v at(1) split("\"") at(0) println) ex catch(Exception, writeln("it doesn't exist."))) writeln()))) # main function # if (args size > 2, atoms := args slice(1, -1) map(asUppercase) ebuildf := Ebuild clone ebuildf getAtom(atoms, args last), "please use: #{args at(0)} , .. " interpolate println)