# -*- coding: utf-8 -*-
"""Console script for secure_data_store."""
import click
from . import secure_data_store as sds

CONFIG='~/.sdsrc'

@click.group()
def main():
    """Wrapper for GoCryptFS"""

@main.command()
@click.argument('name')
@click.option('--config', help='Path to config file', default='~/.sdsrc')
def create(name, config=None):
    """Create a new secure data container NAME."""
    try:
        config = sds.read_config(config)
        sds.create(config, name)
    except (sds.ContainerError, sds.GCFSError, FileExistsError, sds.ConfigError) as err:
        print(err)

@main.command()
@click.argument('name')
@click.option('--config', help='Path to config file', default='~/.sdsrc')
def open(name, config=None):
    """Open an existing secure data container NAME.

    Will print path to the opened, clear-text container."""
    try:
        config = sds.read_config(config)
        sds.mount(config, name)
    except (sds.ContainerError, sds.GCFSError, sds.ConfigError, sds.MountError) as err:
        print(err)

@main.command()
@click.argument('name')
@click.option('--config', help='Path to config file', default='~/.sdsrc')
def close(name, config=None):
    """Close an opend data container NAME."""
    try:
        config = sds.read_config(config)
        sds.unmount(config, name)
    except (sds.ContainerError, sds.GCFSError, sds.ConfigError) as err:
        print(err)

main()

[((8, 1, 8, 14), 'click.group', 'click.group', ({}, {}), '()', False, 'import click\n'), ((13, 1, 13, 23), 'click.argument', 'click.argument', ({(13, 16, 13, 22): '"""name"""'}, {}), "('name')", False, 'import click\n'), ((14, 1, 14, 73), 'click.option', 'click.option', (), '', False, 'import click\n'), ((24, 1, 24, 23), 'click.argument', 'click.argument', ({(24, 16, 24, 22): '"""name"""'}, {}), "('name')", False, 'import click\n'), ((25, 1, 25, 73), 'click.option', 'click.option', (), '', False, 'import click\n'), ((37, 1, 37, 23), 'click.argument', 'click.argument', ({(37, 16, 37, 22): '"""name"""'}, {}), "('name')", False, 'import click\n'), ((38, 1, 38, 73), 'click.option', 'click.option', (), '', False, 'import click\n')]