#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
from maraithal.lsbstegano import LSBStegano
import argparse
from getpass import getpass
try:
    raw_input
except NameError:
    raw_input = input

def main():
    """
    Main function for app
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('mode', help='enc or dec to encode or decode text respectively')
    parser.add_argument('image', help='Path to PNG image to be used')
    parser.add_argument('--message-file', help='File to read text from')
    parser.add_argument('--passphrase', help='Passphrase to use while encoding or decoding')
    args = parser.parse_args()

    if args.mode == 'enc':
        lsb = LSBStegano(args.image)
        key = args.passphrase if args.passphrase else getpass()
        print('Message:', end='')
        text = raw_input()
        lsb.text_encode(text, key)
    elif args.mode == 'dec':
        lsb = LSBStegano(args.image)
        key = args.passphrase if args.passphrase else getpass()
        print(lsb.text_decode(key))

if __name__ == '__main__':
    main()

