#!/usr/bin/python3
# -*- coding: utf-8 -*-

#==============================================================================
# Copyright (C) 2011 by Loïc Grobol
#
# This file is part of CTESLO.
# 
#    CTESLO is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
# 
#    CTESLO is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
# 
#    You should have received a copy of the GNU General Public License
#    along with CTESLO.  If not, see <http://www.gnu.org/licenses/>.
#==============================================================================


"""
Created on 3 sept. 2011

@author: Loïc Grobol <loic.grobol@gmail.com>

A dummy "do nothing" utility. Placeholder for formats tools
when nothing is to be done.

It just pipes stdin/--in-stream/-in to stdout/--out-stream/-o.
"""

import argparse, sys

def main(argv=sys.argv[1:]):
    """Main function."""
    parser = argparse.ArgumentParser(description="Nil.")
    parser.add_argument("--in_stream", "-i",
                         type=argparse.FileType('r'),
                         default=sys.stdin,
                         help="Input file to be formated. Standard input by default.")
    parser.add_argument("--out_stream", "-o",
                         type=argparse.FileType('w'),
                         default=sys.stdout,
                         help="Formated file to be written. Standard output by default.")
    args = parser.parse_known_args(argv)[0] # Get only known args
    if args.in_stream.isatty():
        parser.print_help()
    else:
        args.out_stream.write(args.in_stream.read())

if __name__ == "__main__":
    sys.exit(main())
