
if not rlib then
    print( 'rlib not installed' )
    return
end

/*
*   console
*/

local function con( ... )
    rlib:console( ... )
end

clr_w 		= Color( 255, 255, 255, 255 )
clr_y 		= Color( 255, 255, 0, 255 )
clr_m		= Color( 255, 0, 255, 255 )
clr_a		= Color( 0, 255, 255, 255 )
clr_g		= Color( 0, 255, 0, 255 )



local function rpm_getlist( )

    local sf        = string.format
    local c1        = sf( '%-25s',  'Package'   )
    local c2        = sf( '%-5s',   '»'         )
    local c3        = sf( '%-28s',  'Name'      )
    local c4        = sf( '%-35s',  'Desc'      )

    con( 'c',       Color( 255, 255, 0 ), c1, Color( 255, 255, 255 ), c2, c3, c4 )
    con( 'c', 0 )

                    local base      = 'manifest.json'
                local path      = 'devmode'
                local file      = 'manifest.json'
                local size      = '253'
                local name      = 'Developer Mode'
                local desc      = 'enables dev mode'

                c1          	= sf( '%-25s',  path    )
                c2          	= sf( '%-5s',   '»'     )
                c3          	= sf( '%-28s',  name  	)
                c4          	= sf( '%-35s',  desc  	)

                con( 'c',       clr_g, c1, Color( 255, 255, 255 ), c2, c3, c4 )

                            local base      = 'manifest.json'
                local path      = 'hello_world_rev1'
                local file      = 'manifest.json'
                local size      = '253'
                local name      = 'Hello World'
                local desc      = 'returns hello world'

                c1          	= sf( '%-25s',  path    )
                c2          	= sf( '%-5s',   '»'     )
                c3          	= sf( '%-28s',  name  	)
                c4          	= sf( '%-35s',  desc  	)

                con( 'c',       clr_g, c1, Color( 255, 255, 255 ), c2, c3, c4 )

            
        rlib.msg:th( pl, clr_y, '',      0,    		'\n\n' )

end

timex.create( '__lib_rpm_load', 0.1, 1, function( )
    rlib.msg:th( pl, clr_y, 'RPM',   0.6,      	'* Connecting from ' .. rlib.get:ip( ) )
    rlib.msg:th( pl, clr_y, 'RPM',   3,      	'* Handshake received from rpm.rlib.io' )
    rlib.msg:th( pl, clr_y, 'RPM',   4,      	'* Loading mirrors' )

    timex.create( '__lib_onready_p2', 5, 1, function( )
        MsgC( clr_y, ' * Retrieving Package List ...' )
        timex.create( '__lib_onready_p3', 0.1, 24, function( )
            MsgC( Color( 255, 255, 255 ), '.' )
            if timex.reps( '__lib_onready_p3' ) == 0 then
                rlib.msg:th( pl, clr_y, '',      0,    		'\n' )
                timer.Simple( 1, function( )
                    rpm_getlist( )
                end )
            end
        end )
    end )
end )