view commitwatcher/main.py @ 45:32cf3d3469c3 default tip

assert
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 07 Nov 2013 14:19:06 -0800
parents 4cb3971d9d9d
children
line wrap: on
line source

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
new service to monitor mozbase commits
"""

import optparse
import os
import subprocess
import sys

from .agent import FeedAgent

def add_options(parser):
    """add options to the OptionParser instance"""

def main(args=sys.argv[1:]):

    # parse command line options
    usage = '%prog [options] url://of.repository/'
    class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
        """description formatter for console script entry point"""
        def format_description(self, description):
            if description:
                return description.strip() + '\n'
            else:
                return ''
    parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
    options, args = parser.parse_args(args)
    if len(args) != 1:
        parser.error("Please specify a single repository")
        # TODO : multiple repos

    repo = args[0]

    # watch the damn thing
    watcher = FeedAgent(repository=repo)
    watcher.update()

if __name__ == '__main__':
  main()