#!/usr/bin/python3 -sP
#-*- coding: utf-8 -*-

from Oct2spec import oct2rpm
from optparse import OptionParser

#################################################
### argument
# retrieve the arguments given and show the help when needed
def getArgument():
    ''' Handle the parameters'''
    parser = OptionParser(version="%prog 1.0.1")
    parser.add_option("-u", "--url", dest="url",
                        help="Url of the Octave package")
    parser.add_option("-s", "--source", dest="source",
                        help="The source file (tarball) of the Octave package")
    parser.add_option("-p", "--package", dest="package",
                  help="The name of the Octave package")
                  
    parser.add_option("--forge", dest="forge", default=True, action="store_true",
                        help="For packages coming from the octave.sourceforge.net repository, will add the correct Source0 in the spec file")
                  
    parser.add_option("-c", "--copyFile", dest="copyFile", default=False, action="store_true",
                        help="Copy directly the file to the SOURCES folder without asking")
    parser.add_option("-d", "--dependencies", dest="dependencies", default=False, action="store_true",
                        help="Build the dependencies is any missing (default is False)")
                  
    parser.add_option("-n", "--name", dest="name",
                        help="Name of the packager that will be used in the spec file")
    parser.add_option("-e", "--email", dest="email",
                        help="Email of the packager that will be used in the spec file")
    parser.add_option("-f", "--force", dest="force", default=False, action="store_true",
                        help="Create the spec file even if a file of the same name exists allready in the working directory")
    
    parser.add_option("--mock", dest="mock", default=False,
                        help="Mock config file to build the RPMs, if not specified it uses rpmbuild (default)")
    
    (options, args) = parser.parse_args()

    return (options.source, options.url, options.package, \
        options.forge, \
        options.copyFile, options.dependencies, options.name, \
        options.email, options.force, options.mock)
################################################

if __name__ == "__main__":
    # Start
    # Retrieve the given arguments
    (source, url, package, forge, copyFile, \
        dependencies, name, email, force, mock) = getArgument()
    oct2rpm.oct2rpm().main(source, url, package, forge, copyFile,\
        dependencies, name, email, force, mock)

