'Implement command'

def func(self):

    caller = self.caller
    switches = self.switches
    if (switches and (switches[0] not in ('list', 'start', 'stop', 'delete'))):
        caller.msg('Usage:    @service/<list|start|stop|delete>    [servicename]')
        return
    service_collection = SESSIONS.server.services
    if ((not switches) or (switches[0] == 'list')):
        table = EvTable('|wService|n    (use    @services/start|stop|delete)', '|wstatus', align='l')
        for service in service_collection.services:
            table.add_row(service.name, ((service.running and '|gRunning') or '|rNot    Running'))
        caller.msg(unicode(table))
        return
    try:
        service = service_collection.getServiceNamed(self.args)
    except Exception:
        string = 'Invalid    service    name.    This    command    is    case-sensitive.    '
        string += 'See    @service/list    for    valid    service    name    (enter    the    full    name    exactly).'
        caller.msg(string)
        return
    if (switches[0] in ('stop', 'delete')):
        delmode = (switches[0] == 'delete')
        if (not service.running):
            caller.msg('That    service    is    not    currently    running.')
            return
        if (service.name[:7] == 'Evennia'):
            if delmode:
                caller.msg("You    cannot    remove    a    core    Evennia    service    (named    'Evennia***').")
                return
            string = "You    seem    to    be    shutting    down    a    core    Evennia    service    (named    'Evennia***').    Note    that"
            string += 'stopping    some    TCP    port    services    will    *not*    disconnect    users    *already*'
            string += 'connected    on    those    ports,    but    *may*    instead    cause    spurious    errors    for    them.    To    '
            string += 'safely    and    permanently    remove    ports,    change    settings    file    and    restart    the    server.'
            caller.msg(string)
        if delmode:
            service.stopService()
            service_collection.removeService(service)
            caller.msg(("Stopped    and    removed    service    '%s'." % self.args))
        else:
            service.stopService()
            caller.msg(("Stopped    service    '%s'." % self.args))
        return
    if (switches[0] == 'start'):
        if service.running:
            caller.msg('That    service    is    already    running.')
            return
        caller.msg(("Starting    service    '%s'." % self.args))
        service.startService()
