#!/usr/bin/python

# Copyright (C) 2011 Javier Palacios
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License Version 2
# as published by the Free Software Foundation.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.


__version__ = "1.0"

__usage__ = """%prog reponame [reponame ...]"""


import sys

import repolib


import optparse

def option_parser () :
    version_string = "%%prog %s" % __version__
    parser = optparse.OptionParser( usage=__usage__ , version=version_string )

    return parser


def main () :

    parser = option_parser()
    opts , args = parser.parse_args()

    if not args :
        parser.print_help()
        sys.exit(1)

    while args :
        repo_name = args.pop()
        try :
            repo = repolib.BuildRepository.new( repo_name )
            repo.build()
        except Exception , ex :
            repolib.logger.critical( "Repo %s : %s" % ( repo_name , ex ) )

if __name__ == "__main__" :
    main()

