#!/usr/bin/python
#
# Copyright (c) 2011 Bogdano Arendartchuk <bogdano@mandriva.com.br>
#
# Written by Bogdano Arendartchuk <bogdano@mandriva.com.br>
#
# This file is part of Jurt Build Bot.
#
# Jurt Build Bot is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# Jurt Build Bot 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.
#
# You should have received a copy of the GNU General Public License
# along with Jurt Build Bot; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
import sys
import os

def usage():
    print """\
jurt - builds packages in a clean root

Before using it, please run jurt-setup.

Basic commands:          (alias)

    jurt-build           (jurt b)
    jurt-shell           (jurt sh)
    jurt-list-targets    (jurt lt)
    jurt-list-roots      (jurt lr)
    jurt-put

For more information run <COMMAND> --help and jurt(1)\
"""

ALIASES = {
    "b": "build",
    "sh": "shell",
    "lr": "list-roots",
    "lt": "list-targets" }

def main():
    if len(sys.argv) < 2:
        usage()
    else:
        dir = os.path.dirname(__file__)
        cmd = ALIASES.get(sys.argv[1], sys.argv[1])
        name = "jurt-" + cmd
        prog = os.path.join(dir, name)
        if os.path.exists(prog):
            args = [name] + sys.argv[2:]
            os.execv(prog, args)
        else:
            usage()

if __name__ == "__main__":
    main()

# vim:ts=4:sw=4:et
