degal/main.py
branchuse-distutils
changeset 48 20355dd2e61a
child 72 168a2d065f17
equal deleted inserted replaced
47:189f331c7960 48:20355dd2e61a
       
     1 """
       
     2     Main entry point for the command-line interface
       
     3 """
       
     4 
       
     5 import commands
       
     6 
       
     7 from optparse import OptionParser
       
     8 
       
     9 def option_parser (command_name) :
       
    10     """
       
    11         Build the OptionParser that we use
       
    12     """
       
    13     
       
    14     # create parser using the given command
       
    15     parser = OptionParser(prog=command_name)
       
    16     
       
    17     # define options
       
    18     parser.add_option('-d', "--dir", dest='dir', help="Use DIR as the image/HTML path [default: CWD]", metavar='DIR', default='.')
       
    19     
       
    20     return parser
       
    21 
       
    22 def main (argv) :
       
    23     """
       
    24         Main entry point
       
    25     """
       
    26 
       
    27     # build optparser
       
    28     parser = option_parser(argv[0])
       
    29     
       
    30     # parse the given argv
       
    31     options, filter_targets = parser.parse_args(argv[1:])
       
    32     
       
    33     # run the selected command
       
    34     return commands.main(options.dir, filter_targets)
       
    35