# Path: syncano_cli/account/command.py
# class AccountCommands(BaseCommand):
# 
#     def __init__(self, config_path):
#         self.connection = syncano.connect()
#         self.config_path = config_path
# 
#     def register(self, email, password, first_name=None, last_name=None):
#         api_key = self.connection.connection().register(
#             email=email,
#             password=password,
#             first_name=first_name,
#             last_name=last_name,
#         )
# 
#         ACCOUNT_CONFIG.set('DEFAULT', 'key', api_key)
#         with open(self.config_path, 'wt') as fp:
#             ACCOUNT_CONFIG.write(fp)
# 
# Path: syncano_cli/base/options.py
# class ColorSchema(object):
#     INFO = 'green'
#     PROMPT = 'cyan'
#     WARNING = 'yellow'
#     ERROR = 'red'
# 
# class SpacedOpt(OptionsBase):
#     OPTIONS = ['space_top', 'space_bottom']
# 
#     def __init__(self, space_top=True, space_bottom=True, **kwargs):
#         super(SpacedOpt, self).__init__(space_top=space_top, space_bottom=space_bottom, **kwargs)
# 
# class WarningOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.WARNING, **kwargs):
#         super(WarningOpt, self).__init__(color=color, **kwargs)
# 
# Path: syncano_cli/config.py
# ACCOUNT_CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.syncano')


import click
from syncano_cli.account.command import AccountCommands
from syncano_cli.base.options import ColorSchema, SpacedOpt, WarningOpt
from syncano_cli.config import ACCOUNT_CONFIG_PATH


@click.group()
def top_account():
    pass


@top_account.group()
@click.pass_context
@click.option('--config', help=u'Account configuration file.')
def accounts(ctx, config):
    """Handle Syncano Account functionality."""
    account_commands = AccountCommands(config_path=config or ACCOUNT_CONFIG_PATH)
    ctx.obj['account_commands'] = account_commands


@accounts.command()
@click.pass_context
def register(ctx):
    """Allows to register new Syncano Account. Email and password are obligatory."""
    account_commands = ctx.obj['account_commands']

# Path: syncano_cli/account/command.py
# class AccountCommands(BaseCommand):
# 
#     def __init__(self, config_path):
#         self.connection = syncano.connect()
#         self.config_path = config_path
# 
#     def register(self, email, password, first_name=None, last_name=None):
#         api_key = self.connection.connection().register(
#             email=email,
#             password=password,
#             first_name=first_name,
#             last_name=last_name,
#         )
# 
#         ACCOUNT_CONFIG.set('DEFAULT', 'key', api_key)
#         with open(self.config_path, 'wt') as fp:
#             ACCOUNT_CONFIG.write(fp)
# 
# Path: syncano_cli/base/options.py
# class ColorSchema(object):
#     INFO = 'green'
#     PROMPT = 'cyan'
#     WARNING = 'yellow'
#     ERROR = 'red'
# 
# class SpacedOpt(OptionsBase):
#     OPTIONS = ['space_top', 'space_bottom']
# 
#     def __init__(self, space_top=True, space_bottom=True, **kwargs):
#         super(SpacedOpt, self).__init__(space_top=space_top, space_bottom=space_bottom, **kwargs)
# 
# class WarningOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.WARNING, **kwargs):
#         super(WarningOpt, self).__init__(color=color, **kwargs)
# 
# Path: syncano_cli/config.py
# ACCOUNT_CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.syncano')


# Path: syncano_cli/account/commands.py
import click
from syncano_cli.account.command import AccountCommands
from syncano_cli.base.options import ColorSchema, SpacedOpt, WarningOpt
from syncano_cli.config import ACCOUNT_CONFIG_PATH



@click.group()
def top_account():
    pass


@top_account.group()
@click.pass_context
@click.option('--config', help=u'Account configuration file.')
def accounts(ctx, config):
    """Handle Syncano Account functionality."""
    account_commands = AccountCommands(config_path=config or ACCOUNT_CONFIG_PATH)
    ctx.obj['account_commands'] = account_commands


@accounts.command()
@click.pass_context
def register(ctx):
    """Allows to register new Syncano Account. Email and password are obligatory."""
    account_commands = ctx.obj['account_commands']

    account_commands.formatter.write('Create an account in Syncano.', SpacedOpt(), WarningOpt())