#!/usr/bin/python
###############################################################################
#                                                                             #
#    vitalharsharm                                                            #
#                                                                             #
#    Entry point. See vitalharsharm/vitalharsharm.py for internals            #
#                                                                             #
#    Copyright (C) Michael Imelfort                                           #
#                                                                             #
###############################################################################
#                                                                             #
#        888     888 d8b 888    888                 d8888 8888888b.           #
#        888     888 Y8P 888    888                d88888 888   Y88b          #
#        888     888     888    888               d88P888 888    888          #
#        Y88b   d88P 888 8888888888  8888b.      d88P 888 888   d88P          #
#         Y88b d88P  888 888    888     "88b    d88P  888 8888888P"           #
#          Y88o88P   888 888    888 .d888888   d88P   888 888 T88b            #
#           Y888P    888 888    888 888  888  d8888888888 888  T88b           #
#            Y8P     888 888    888 "Y888888 d88P     888 888   T88b          #
#                                                                             #
###############################################################################
#                                                                             #
#    This program 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 3 of the License, or        #
#    (at your option) any later version.                                      #
#                                                                             #
#    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.                             #
#                                                                             #
#    You should have received a copy of the GNU General Public License        #
#    along with this program. If not, see <http://www.gnu.org/licenses/>.     #
#                                                                             #
###############################################################################

__author__ = "Michael Imelfort"
__copyright__ = "Copyright 2012"
__credits__ = ["Michael Imelfort"]
__license__ = "LGPL2.1"
__version__ = "0.1.0"
__maintainer__ = "Michael Imelfort"
__email__ = "mike@mikeimelfort.com"
__status__ = "Alpha"

###############################################################################

import argparse
import sys

# VHA imports
from vitalharsharm.VHAUtils import TCBuilder

###############################################################################
###############################################################################
###############################################################################
###############################################################################

def doWork(args):
    """Wrapper function to allow easy profiling"""
    TCB = TCBuilder()
    TCB.loadTemplate(args.template)
    TCB.createClasses(args.folder, makeTest=args.test)

###############################################################################
###############################################################################
###############################################################################
###############################################################################
def printHelp():
    print '''\

            ...::: vitalHarshArm :::...

       Making memory rad C++ classes for kix

    -----------------------------------------
                 version: %s
    -----------------------------------------

    usage:

    vitalHarshArm <template> [-f <folder>] [-s <silent>]

''' % __version__

if __name__ == '__main__':
#-------------------------------------------------
    # intialise the options parser
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
                                     description='Making memory rad C++ classes for kix')
    parser.add_argument('template', help="template file for the classes")
    parser.add_argument('-f', '--folder', default='.', help="folder to write to")
    parser.add_argument('-t', '--test', action="store_true", default=False, help="create makefile and testing platform")

    #-------------------------------------------------
    # get and check options
    args = None
    if(len(sys.argv) == 1 or sys.argv[1] == '-h' or sys.argv == '--help'):
        printHelp()
        sys.exit(0)
    else:
        args = parser.parse_args()

    # profiling happens here. If you'd like to track the speed your code runs at
    # then set the following to True and voila!
    if(False):
        import cProfile
        cProfile.run('doWork(args)', 'profile')
        ##########################################
        ##########################################
        # Use this in python console!
        #import pstats
        #p = pstats.Stats('prof')
        #p.sort_stats('cumulative').print_stats(10)
        #p.sort_stats('time').print_stats(10)
        ##########################################
        ##########################################
    else:
        doWork(args)

###############################################################################
###############################################################################
###############################################################################
###############################################################################

