# Path: ecmcli/commands/base.py
# def toxml(data, root_tag='ecmcli'):
#     def crawl(obj, parent):
# def totuples(data):
#     def crawl(obj, path):
# def todict(obj, str_array_keys=False):
#     def api_complete(self, resource, field, startswith):
#     def make_completer(self, resource, field):
#         def cached(startswith):
#         def wrap(startswith, *args):
#     def api_search(self, resource, fields, terms, match='icontains',
#                    **options):
#     def res_flatten(self, resource, fields):
#     def confirm(self, msg, exit=True):
#     def make_searcher(self, resource, field_desc, **search_options):
#         def lookup(terms, **options):
#         def complete(startswith, args):
#     def add_completer_argument(self, *keys, resource=None, res_field=None,
#                                **options):
#     def add_router_argument(self, *keys, **options):
#     def add_group_argument(self, *keys, **options):
#     def add_account_argument(self, *keys, **options):
#     def add_product_argument(self, *keys, **options):
#     def add_firmware_argument(self, *keys, **options):
#     def add_role_argument(self, *keys, **options):
#     def add_user_argument(self, *keys, **options):
#     def add_search_argument(self, searcher, *keys, **options):
#     def inject_table_factory(self, *args, **kwargs):
#         def setup_make_table(argument_ns):
# class ECMCommand(shellish.Command):
# 
# Path: ecmcli/commands/shtools.py
# class Debug(base.ECMCommand):
#     def run(self, args):


import importlib
import logging
import pkg_resources
import shellish
import shellish.logging
import sys
from . import api
from .commands import base, shtools
from shellish.command import contrib
        'Welcome to the ECM shell.',
        'Type "help" or "?" to list commands and "exit" to quit.'
    ])

    def verror(self, *args, **kwargs):
        msg = ' '.join(map(str, args))
        shellish.vtmlprint(msg, file=sys.stderr, **kwargs)

    def prompt_info(self):
        info = super().prompt_info()
        ident = self.root_command.api.ident
        username = ident['user']['username'] if ident else '*LOGGED_OUT*'
        info.update({
            "user": username,
            "site": self.root_command.api.site.split('//', 1)[1]
        })
        return info

    def execute(self, *args, **kwargs):
        try:
            return super().execute(*args, **kwargs)
        except api.TOSRequired:
            self.verror('TOS Acceptance Required')
            input('Press <enter> to review TOS')
            return self.root_command['tos']['accept'](argv='')
        except api.AuthFailure as e:
            self.verror('Auth error:' % e)
            return self.root_command['login'](argv='')



# Path: ecmcli/commands/base.py
# def toxml(data, root_tag='ecmcli'):
#     def crawl(obj, parent):
# def totuples(data):
#     def crawl(obj, path):
# def todict(obj, str_array_keys=False):
#     def api_complete(self, resource, field, startswith):
#     def make_completer(self, resource, field):
#         def cached(startswith):
#         def wrap(startswith, *args):
#     def api_search(self, resource, fields, terms, match='icontains',
#                    **options):
#     def res_flatten(self, resource, fields):
#     def confirm(self, msg, exit=True):
#     def make_searcher(self, resource, field_desc, **search_options):
#         def lookup(terms, **options):
#         def complete(startswith, args):
#     def add_completer_argument(self, *keys, resource=None, res_field=None,
#                                **options):
#     def add_router_argument(self, *keys, **options):
#     def add_group_argument(self, *keys, **options):
#     def add_account_argument(self, *keys, **options):
#     def add_product_argument(self, *keys, **options):
#     def add_firmware_argument(self, *keys, **options):
#     def add_role_argument(self, *keys, **options):
#     def add_user_argument(self, *keys, **options):
#     def add_search_argument(self, searcher, *keys, **options):
#     def inject_table_factory(self, *args, **kwargs):
#         def setup_make_table(argument_ns):
# class ECMCommand(shellish.Command):
# 
# Path: ecmcli/commands/shtools.py
# class Debug(base.ECMCommand):
#     def run(self, args):


# Path: ecmcli/main.py
import importlib
import logging
import pkg_resources
import shellish
import shellish.logging
import sys
from . import api
from .commands import base, shtools
from shellish.command import contrib

        'Welcome to the ECM shell.',
        'Type "help" or "?" to list commands and "exit" to quit.'
    ])

    def verror(self, *args, **kwargs):
        msg = ' '.join(map(str, args))
        shellish.vtmlprint(msg, file=sys.stderr, **kwargs)

    def prompt_info(self):
        info = super().prompt_info()
        ident = self.root_command.api.ident
        username = ident['user']['username'] if ident else '*LOGGED_OUT*'
        info.update({
            "user": username,
            "site": self.root_command.api.site.split('//', 1)[1]
        })
        return info

    def execute(self, *args, **kwargs):
        try:
            return super().execute(*args, **kwargs)
        except api.TOSRequired:
            self.verror('TOS Acceptance Required')
            input('Press <enter> to review TOS')
            return self.root_command['tos']['accept'](argv='')
        except api.AuthFailure as e:
            self.verror('Auth error:' % e)
            return self.root_command['login'](argv='')



class ECMRoot(base.ECMCommand):