#!/bin/python3

"""
This script "latches" a given folder.
"""

# Standard imports.
import argparse
from getpass import getpass

# Bespoke imports.
from hoskerlatch import latch

#############
# FUNCTIONS #
#############

def make_parser():
    """ Make the parser object. """
    desc_str = '"Latch" a given folder'
    result = argparse.ArgumentParser(description=desc_str)
    result.add_argument(
        "path_to_folder",
        help="The path to the folder to be latched"
    )
    result.add_argument(
        "--resalt",
        action="store_true",
        help="Replace the salt file"
    )
    return result

###################
# RUN AND WRAP UP #
###################

def run():
    """ Run this file. """
    parser = make_parser()
    arguments = parser.parse_args()
    path_to_folder = arguments.path_to_folder
    password = getpass()
    resalt = arguments.resalt
    path_to_encrypted = latch(path_to_folder, password, resalt=resalt)
    print("Latched to: "+path_to_encrypted)

if __name__ == "__main__":
    run()
