'List containers.
Usage: ps [options] [SERVICE...]
Options:
-q    Only display IDs'

def ps(self, options):

    containers = sorted((self.project.containers(service_names=options[u'SERVICE'], stopped=True) + self.project.containers(service_names=options[u'SERVICE'], one_off=OneOffFilter.only)), key=attrgetter(u'name'))
    if options[u'-q']:
        for container in containers:
            print(container.id)
    else:
        headers = [u'Name', u'Command', u'State', u'Ports']
        rows = []
        for container in containers:
            command = container.human_readable_command
            if (len(command) > 30):
                command = (u'%s    ...' % command[:26])
            rows.append([container.name, command, container.human_readable_state, container.human_readable_ports])
        print(Formatter().table(headers, rows))
