add option to list all processes

Signed-off-by: Collins Abitekaniza <abtcolns@gmail.com>
This commit is contained in:
Collins Abitekaniza 2018-11-06 14:39:53 +03:00
parent 8edb0d872d
commit ba1e0311a7

View File

@ -694,6 +694,7 @@ class TopLevelCommand(object):
-q, --quiet Only display IDs -q, --quiet Only display IDs
--services Display services --services Display services
--filter KEY=VAL Filter services by a property --filter KEY=VAL Filter services by a property
-a, --all Shows all stopped containers
""" """
if options['--quiet'] and options['--services']: if options['--quiet'] and options['--services']:
raise UserError('--quiet and --services cannot be combined') raise UserError('--quiet and --services cannot be combined')
@ -706,10 +707,14 @@ class TopLevelCommand(object):
print('\n'.join(service.name for service in services)) print('\n'.join(service.name for service in services))
return return
containers = sorted( if options['--all']:
self.project.containers(service_names=options['SERVICE'], stopped=True) + containers = sorted(self.project.containers(service_names=options['SERVICE'],
self.project.containers(service_names=options['SERVICE'], one_off=OneOffFilter.only), one_off=OneOffFilter.include, stopped=True))
key=attrgetter('name')) else:
containers = sorted(
self.project.containers(service_names=options['SERVICE'], stopped=True) +
self.project.containers(service_names=options['SERVICE'], one_off=OneOffFilter.only),
key=attrgetter('name'))
if options['--quiet']: if options['--quiet']:
for container in containers: for container in containers: