#!/usr/bin/env python

'''
Callgraph-to-Dot processor.

Converts a callgraph to a GraphViz Dot file.

Usage:
    cgdot <callgraph> [--output=<dotfile>]

Options:
    -o --output=<dotfile>    Output file (Graphviz .dot format)
'''

import cgnet
import docopt

args = docopt.docopt(__doc__)

cgname = args['<callgraph>']
cgfile = open(cgname, 'r')

filename = args['<dotfile>'] if '<dotfile>' in args else cgname + '.dot'
outfile = open(filename, 'w')

graph = cgnet.load(cgfile, cgname)
graph.to_dot(outfile)
