# -*- 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()

[((141, 154), 'click.group', 'click.group', ([], {}), '()\n', (152, 154), False, 'import click\n'), ((217, 239), 'click.argument', 'click.argument', (['"""name"""'], {}), "('name')\n", (231, 239), False, 'import click\n'), ((241, 313), 'click.option', 'click.option', (['"""--config"""'], {'help': '"""Path to config file"""', 'default': '"""~/.sdsrc"""'}), "('--config', help='Path to config file', default='~/.sdsrc')\n", (253, 313), False, 'import click\n'), ((605, 627), 'click.argument', 'click.argument', (['"""name"""'], {}), "('name')\n", (619, 627), False, 'import click\n'), ((629, 701), 'click.option', 'click.option', (['"""--config"""'], {'help': '"""Path to config file"""', 'default': '"""~/.sdsrc"""'}), "('--config', help='Path to config file', default='~/.sdsrc')\n", (641, 701), False, 'import click\n'), ((1051, 1073), 'click.argument', 'click.argument', (['"""name"""'], {}), "('name')\n", (1065, 1073), False, 'import click\n'), ((1075, 1147), 'click.option', 'click.option', (['"""--config"""'], {'help': '"""Path to config file"""', 'default': '"""~/.sdsrc"""'}), "('--config', help='Path to config file', default='~/.sdsrc')\n", (1087, 1147), False, 'import click\n')]