#!/usr/bin/env python

import sys
from optparse import OptionParser
from ceres import CeresTree


parser = OptionParser(usage='''%prog [options] <path/to/tree/root/> <metric-pattern>''')
parser.add_option('--fromtime', default=None, type='int')
parser.add_option('--untiltime', default=None, type='int')
parser.add_option('--fspath', action='store_true')

options, args = parser.parse_args()

if len(args) < 2:
  parser.print_usage()
  sys.exit(1)


root_dir = args[0]
pattern = args[1]
tree = CeresTree(root_dir)

for node in tree.find(pattern, fromTime=options.fromtime, untilTime=options.untiltime):
  if options.fspath:
    print node.fsPath
  else:
    print node.nodePath
