-- extract package information for specified package(s).
-- get list of package from standard input.


-- function. split strings and store it into table
--
function split(str, d)

    local s = str
    local tbl = {}
    local p = "%s*(.-)%s*"..d.."%s*"
    local f = function(v)
        table.insert(tbl, v)
    end

    if s ~= nill then
        string.gsub(s, p, f)
        f(string.gsub(s, p, ""))
    end
    return tbl

end

-- main. read standard input and outpu package information 
--
apps = split(io.read()," ")

for i, name in pairs(apps) do
    if pkgfind(name) then
        print("Package: "..pkgname(name))
        print("Summary: "..pkgsummary(name))
        print("Description: \n"..pkgdescr(name))
        if pkgvercur(name) then
            print("State: Installed")
        else
            print("State: NotInstalled")
        end
    end
end



