#!/usr/bin/env python

import sys
from optparse import OptionParser
from ceres import CeresTree, getTree


parser = OptionParser(usage='''%prog [options] <path>
  If --tree is specified, <path> is taken as a node path
  Otherwise <path> is taken as a filesystem path
''')
parser.add_option('--tree', default=None)
parser.add_option('--step', default=60, type='int', help="Default time step")

options, args = parser.parse_args()

if not args:
  parser.print_usage()
  sys.exit(1)


if options.tree:
  nodePath = args[0]
  tree = CeresTree(options.tree)

else:
  fsPath = args[0]
  tree = getTree(fsPath)

  if not tree:
    print "error: %s is not in a ceres tree" % fsPath
    sys.exit(1)

  nodePath = tree.getNodePath(fsPath)

tree.createNode(nodePath, timeStep=options.step)
