#!/usr/bin/env python

# Copyright 2015 Michael DeHaan <michael.dehaan/gmail>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import sys
from jcp import JCopy, JCopyException

DESC = '''
jcp is a template aware copy program
'''

parser = argparse.ArgumentParser(
    prog='jcp',
    description=DESC
)

# may support other template engines later, want to add --engine?  Send me a patch!
parser.add_argument("--input", required=True, help="input template filename (jinja2 format)")
# would be nice to dump to stdout if no --output parameter?  Send me a patch!
parser.add_argument("--output", help="output filename (output to stdout if not specified)")
# want to support other formats?  Send me a patch!
parser.add_argument("--answers", required=True, help="answers filename (YAML or JSON)")

args = parser.parse_args()

try:

    grand_arbiter_of_copying = JCopy(args.answers)
    rc = grand_arbiter_of_copying.copy(args.input, args.output)
except JCopyException, jce:
    print jce.message
    sys.exit(1)
