From ba1e0311a7e9c02ff5a2751a62062aedba151314 Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Tue, 6 Nov 2018 14:39:53 +0300 Subject: [PATCH 1/3] add option to list all processes Signed-off-by: Collins Abitekaniza --- compose/cli/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index afe813ee5..e96aac031 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -694,6 +694,7 @@ class TopLevelCommand(object): -q, --quiet Only display IDs --services Display services --filter KEY=VAL Filter services by a property + -a, --all Shows all stopped containers """ if options['--quiet'] and options['--services']: raise UserError('--quiet and --services cannot be combined') @@ -706,10 +707,14 @@ class TopLevelCommand(object): print('\n'.join(service.name for service in services)) return - 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['--all']: + containers = sorted(self.project.containers(service_names=options['SERVICE'], + one_off=OneOffFilter.include, stopped=True)) + 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']: for container in containers: From 05efe52ccd1c1d64a87e906b389ef31d948067e9 Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Tue, 6 Nov 2018 14:49:56 +0300 Subject: [PATCH 2/3] test --all flag Signed-off-by: Collins Abitekaniza --- compose/cli/main.py | 2 +- tests/acceptance/cli_test.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index e96aac031..f64af8948 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -694,7 +694,7 @@ class TopLevelCommand(object): -q, --quiet Only display IDs --services Display services --filter KEY=VAL Filter services by a property - -a, --all Shows all stopped containers + -a, --all Show all stopped containers """ if options['--quiet'] and options['--services']: raise UserError('--quiet and --services cannot be combined') diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 5b0a0e0fd..f42268f2c 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -599,6 +599,14 @@ class CLITestCase(DockerClientTestCase): assert 'with_build' 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): result = self.dispatch(['pull']) assert 'Pulling simple' in result.stderr From e0e06a4b5627cdccf2408f2a2e91125c4d0ea8b8 Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Thu, 15 Nov 2018 15:24:50 +0300 Subject: [PATCH 3/3] add detail to description for --all flag Signed-off-by: Collins Abitekaniza --- compose/cli/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index f64af8948..e9c7dbb43 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -694,7 +694,7 @@ class TopLevelCommand(object): -q, --quiet Only display IDs --services Display services --filter KEY=VAL Filter services by a property - -a, --all Show all stopped containers + -a, --all Show all stopped containers (including those created by the run command) """ if options['--quiet'] and options['--services']: raise UserError('--quiet and --services cannot be combined')