degal/main.py
author Tero Marttila <terom@fixme.fi>
Wed, 03 Jun 2009 20:33:15 +0300
branchuse-distutils
changeset 48 20355dd2e61a
child 72 168a2d065f17
permissions -rw-r--r--
new structure for bin/degal, adding degal/commands, degal/main
"""
    Main entry point for the command-line interface
"""

import commands

from optparse import OptionParser

def option_parser (command_name) :
    """
        Build the OptionParser that we use
    """
    
    # create parser using the given command
    parser = OptionParser(prog=command_name)
    
    # define options
    parser.add_option('-d', "--dir", dest='dir', help="Use DIR as the image/HTML path [default: CWD]", metavar='DIR', default='.')
    
    return parser

def main (argv) :
    """
        Main entry point
    """

    # build optparser
    parser = option_parser(argv[0])
    
    # parse the given argv
    options, filter_targets = parser.parse_args(argv[1:])
    
    # run the selected command
    return commands.main(options.dir, filter_targets)