#!python
""" Convert notebook to Sphinx ReST format with nbplot directives

Example:

    nb2plots example.ipynb

Prints to stdout with UTF-8 encoding.
"""
# vim: ft=python
from __future__ import division, print_function, absolute_import

from argparse import ArgumentParser

from nb2plots.commands import bin_stdout
from nb2plots.from_notebook import convert_nb_fname


def main():
    parser = ArgumentParser(
        description="Convert notebook to ReST format with plot directives")
    parser.add_argument('notebook', help = 'notebook file to convert')
    args = parser.parse_args()
    rst_text = convert_nb_fname(args.notebook) + '\n'
    bin_stdout().write(rst_text.encode('utf-8'))


if __name__ == '__main__':
    main()
