#!/usr/bin/python
# Filename:      
# Purpose:       builds automatically all asciidoc html files
# Authors:       (c) Michael Gebetsroither <gebi@grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2.
################################################################################

import sys
import os
import optparse
import hgutil.hg.util as hgutil
from hgutil.hg.util import ishgrep


if __name__ == "__main__":
    usage = "usage: %prog [options] <dir1> <dir2> ...\n\n" +\
            "%prog is a program to scan for mercurial repositories in\nthe given directories."
    parser = optparse.OptionParser(usage)
    parser.add_option("-r", "--recursive", action="store_true", dest="recursive", default=False,
            help="Search the given directories recursive for mercurial repositories")
    (opts, args) = parser.parse_args()
    walkfunc = hgutil.walkrepos_flat
    printfunc = lambda x: sys.stdout.write(x + '\n')
    if opts.recursive:
        walkfunc = hgutil.walkrepos
    if len(args) == 0:
        args.append(".")
    for i in args:
        filter(printfunc, walkfunc(i))
