mirror of https://github.com/docker/compose.git
Merge pull request #6327 from collin5/b6271
Add option for `--all` flag to `ps`
This commit is contained in:
commit
e86e10fb6b
|
@ -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 Show all stopped containers (including those created by the run command)
|
||||||
"""
|
"""
|
||||||
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:
|
||||||
|
|
|
@ -599,6 +599,14 @@ class CLITestCase(DockerClientTestCase):
|
||||||
assert 'with_build' in running.stdout
|
assert 'with_build' in running.stdout
|
||||||
assert 'with_image' in running.stdout
|
assert 'with_image' in running.stdout
|
||||||
|
|
||||||
|
def test_ps_all(self):
|
||||||
|
self.project.get_service('simple').create_container(one_off='blahblah')
|
||||||
|
result = self.dispatch(['ps'])
|
||||||
|
assert 'simple-composefile_simple_run_1' not in result.stdout
|
||||||
|
|
||||||
|
result2 = self.dispatch(['ps', '--all'])
|
||||||
|
assert 'simple-composefile_simple_run_1' in result2.stdout
|
||||||
|
|
||||||
def test_pull(self):
|
def test_pull(self):
|
||||||
result = self.dispatch(['pull'])
|
result = self.dispatch(['pull'])
|
||||||
assert 'Pulling simple' in result.stderr
|
assert 'Pulling simple' in result.stderr
|
||||||
|
|
Loading…
Reference in New Issue