#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2010 by Intevation GmbH
# Authors:
# Bjoern Ricks <bjoern.ricks@intevation.de>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with the software for details.

import sys

from optparse import OptionParser
from porttemplate import PortTemplate

def main():
    parser = OptionParser()
    parser.add_option("-i", "--in", dest="inputfile", help="Load template " \
                      " from this file")
    parser.add_option("-o", "--out", dest="outfile", help="Output file")
    parser.add_option("--subdir", dest="subdir", help="Subdirectory to check" \
                     " in svn")
    parser.add_option("--scm", dest="scm", help="SCM to use i.e. svn or git")
    (options, args) = parser.parse_args()

    if not options.inputfile:
        print >> sys.stderr, "Not enough arguments. Please provide a" \
                             " template file"
        sys.exit(1)

    if not options.subdir:
        print >> sys.stderr, "Not enough arguments. Please specify a" \
                             " subdirectoy for svn"
        sys.exit(2)

    ptemplate = PortTemplate(options.subdir, options.inputfile, options.outfile,
                             "svn://anonsvn.kde.org/home/kde/tags/kdepim/", 
                             "^enterprise5\.0\.[0-9]+\.[0-9]+$",
                             options.subdir, options.scm)
    if options.outfile:
        ptemplate.write()
    else:
        print ptemplate.substitute()

if __name__ == '__main__':
    main()

# vim:fenc=utf-8:et:sw=4:ts=4:tw=80: 
