#!/usr/bin/env python3

import sys
from rst2ansi import rst2ansi
import argparse

parser = argparse.ArgumentParser(description='Prints a reStructuredText input in an ansi-decorated format suitable for console output.')
parser.add_argument('file', type=str, nargs='?', help='A path to the file to open')

args = parser.parse_args()

def process_file(f):
  print(rst2ansi(f.read()))

if args.file:
  with open(args.file, 'r') as f:
    process_file(f)
else:
  process_file(sys.stdin)

