# Path: aeriscloud/cli/helpers.py
# class Command(click.Command):
#     # This is inherited by the Context to switch between pure POSIX and
#     # argparse-like argument parsing. Setting it to false will push any
#     # unknown flag to the argument located where the flag was declared
#     allow_interspersed_args = config.get('config', 'posix', default=False)
# 
#     def __init__(self, *args, **kwargs):
#         cs = dict(help_option_names=['-h', '--help'])
#         super(Command, self).__init__(context_settings=cs,
#                                       *args, **kwargs)
# 
# class CLITable(object):
#     """
#     Helps displaying a dynamically sized table a la docker ps
#     """
#     COL_PADDING = 2
# 
#     def __init__(self, *cols):
#         self._cols = cols
#         self._header_out = False
# 
#     def _str(self, data, size):
#         str_real_len = len(strip_ansi(data))
#         return data + (' ' * (size - str_real_len))
# 
#     def _compute_col_sizes(self, data):
#         sizes = {}
#         # prepend data with header
#         data = [dict(zip(self._cols, self._cols))] + data
#         for row in data:
#             for name, row_data in row.iteritems():
#                 real_len = len(strip_ansi(row_data))
#                 if name not in sizes or real_len > sizes[name]:
#                     sizes[name] = real_len
#         # filter unknown values
#         self._sizes = dict([
#             (key, length + self.COL_PADDING)
#             for key, length in sizes.iteritems()
#             if key in self._cols
#         ])
# 
#     def _header(self):
#         if self._header_out:
#             return
# 
#         self._header_out = True
#         for name in self._cols:
#             click.echo(self._str(name.upper(), self._sizes[name]), nl=False)
#         click.echo('')
# 
#     def echo(self, data):
#         if not isinstance(data, list):
#             data = [data]
# 
#         self._compute_col_sizes(data)
#         self._header()
# 
#         for row in data:
#             for name in self._cols:
#                 row_data = ''
#                 if name in row:
#                     row_data = row[name]
#                 click.echo(self._str(row_data, self._sizes[name]), nl=False)
#             click.echo('')
# 
# def success(text, **kwargs):
#     click.secho(text, fg='green', **kwargs)
# 
# def fatal(text, code=1, **kwargs):
#     error(text, **kwargs)
#     sys.exit(code)
# 
# Path: aeriscloud/config.py
# def expose_url():
#     return config.get('aeris', 'url', default=None)
# 
# def expose_username():
#     email = config.get('aeris', 'email', default=None)
#     if not email:
#         return None
#     return email.split('@')[0]
# 
# Path: aeriscloud/expose.py
# class ExposeError(RuntimeError):
# class ExposeTimeout(ExposeError):
# class ExposeConnectionError(ExposeError):
# class Expose(object):
# class Client:
#     def __init__(self, e):
#     def __init__(self):
#     def load(self):
#     def file(self):
#     def save(self):
#     def start(self):
#     def stop(self):
#     def enabled(self):
#     def announce(self):
#     def add(self, box, announce=True):
#     def remove(self, box, announce=False):
#     def list(self):
#     def __init__(self, email, username=None, password=None, token=None,
#                  api_url=None, fullname=None):
#     def get_email(self):
#     def _do_request(self, type, *args, **kwargs):
#     def set_token(self, token):
#     def get_headers(self, type=None):
#     def get_vms(self):
#     def signup(self, password, fullname=None):
#     def get_user(self, username):
#     def update(self):
#     def service(self, services, replace=False):
#     def get_token(self, password=None):
# def expose_client():


import click
import sys
from functools import update_wrapper
from json import dumps
from requests.exceptions import HTTPError
from aeriscloud.cli.helpers import Command, CLITable, success, fatal
from aeriscloud.config import expose_url, expose_username
from aeriscloud.expose import expose_client, expose
#!/usr/bin/env python





def check_expose(func):
    @click.pass_context
    def _deco(ctx, *args, **kwargs):
        if not expose.enabled():
            click.secho('warning: aeris.cd is not enabled', fg='yellow')
            sys.exit(1)
        try:
            return ctx.invoke(func, *args, **kwargs)
        except HTTPError as e:
            fatal(e.message)
    return update_wrapper(_deco, func)


@click.group()
def cli():
    """
    Manage project exposition
    """
    pass



# Path: aeriscloud/cli/helpers.py
# class Command(click.Command):
#     # This is inherited by the Context to switch between pure POSIX and
#     # argparse-like argument parsing. Setting it to false will push any
#     # unknown flag to the argument located where the flag was declared
#     allow_interspersed_args = config.get('config', 'posix', default=False)
# 
#     def __init__(self, *args, **kwargs):
#         cs = dict(help_option_names=['-h', '--help'])
#         super(Command, self).__init__(context_settings=cs,
#                                       *args, **kwargs)
# 
# class CLITable(object):
#     """
#     Helps displaying a dynamically sized table a la docker ps
#     """
#     COL_PADDING = 2
# 
#     def __init__(self, *cols):
#         self._cols = cols
#         self._header_out = False
# 
#     def _str(self, data, size):
#         str_real_len = len(strip_ansi(data))
#         return data + (' ' * (size - str_real_len))
# 
#     def _compute_col_sizes(self, data):
#         sizes = {}
#         # prepend data with header
#         data = [dict(zip(self._cols, self._cols))] + data
#         for row in data:
#             for name, row_data in row.iteritems():
#                 real_len = len(strip_ansi(row_data))
#                 if name not in sizes or real_len > sizes[name]:
#                     sizes[name] = real_len
#         # filter unknown values
#         self._sizes = dict([
#             (key, length + self.COL_PADDING)
#             for key, length in sizes.iteritems()
#             if key in self._cols
#         ])
# 
#     def _header(self):
#         if self._header_out:
#             return
# 
#         self._header_out = True
#         for name in self._cols:
#             click.echo(self._str(name.upper(), self._sizes[name]), nl=False)
#         click.echo('')
# 
#     def echo(self, data):
#         if not isinstance(data, list):
#             data = [data]
# 
#         self._compute_col_sizes(data)
#         self._header()
# 
#         for row in data:
#             for name in self._cols:
#                 row_data = ''
#                 if name in row:
#                     row_data = row[name]
#                 click.echo(self._str(row_data, self._sizes[name]), nl=False)
#             click.echo('')
# 
# def success(text, **kwargs):
#     click.secho(text, fg='green', **kwargs)
# 
# def fatal(text, code=1, **kwargs):
#     error(text, **kwargs)
#     sys.exit(code)
# 
# Path: aeriscloud/config.py
# def expose_url():
#     return config.get('aeris', 'url', default=None)
# 
# def expose_username():
#     email = config.get('aeris', 'email', default=None)
#     if not email:
#         return None
#     return email.split('@')[0]
# 
# Path: aeriscloud/expose.py
# class ExposeError(RuntimeError):
# class ExposeTimeout(ExposeError):
# class ExposeConnectionError(ExposeError):
# class Expose(object):
# class Client:
#     def __init__(self, e):
#     def __init__(self):
#     def load(self):
#     def file(self):
#     def save(self):
#     def start(self):
#     def stop(self):
#     def enabled(self):
#     def announce(self):
#     def add(self, box, announce=True):
#     def remove(self, box, announce=False):
#     def list(self):
#     def __init__(self, email, username=None, password=None, token=None,
#                  api_url=None, fullname=None):
#     def get_email(self):
#     def _do_request(self, type, *args, **kwargs):
#     def set_token(self, token):
#     def get_headers(self, type=None):
#     def get_vms(self):
#     def signup(self, password, fullname=None):
#     def get_user(self, username):
#     def update(self):
#     def service(self, services, replace=False):
#     def get_token(self, password=None):
# def expose_client():


# Path: aeriscloud/cli/aeris/expose.py
import click
import sys
from functools import update_wrapper
from json import dumps
from requests.exceptions import HTTPError
from aeriscloud.cli.helpers import Command, CLITable, success, fatal
from aeriscloud.config import expose_url, expose_username
from aeriscloud.expose import expose_client, expose

#!/usr/bin/env python





def check_expose(func):
    @click.pass_context
    def _deco(ctx, *args, **kwargs):
        if not expose.enabled():
            click.secho('warning: aeris.cd is not enabled', fg='yellow')
            sys.exit(1)
        try:
            return ctx.invoke(func, *args, **kwargs)
        except HTTPError as e:
            fatal(e.message)
    return update_wrapper(_deco, func)


@click.group()
def cli():
    """
    Manage project exposition
    """
    pass



@cli.command(cls=Command)