diff --git a/compose/cli/main.py b/compose/cli/main.py index 51ba36a09..4c3695504 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -301,6 +301,7 @@ class TopLevelCommand(object): -q, --quiet Only validate the configuration, don't print anything. --services Print the service names, one per line. + --volumes Print the volume names, one per line. """ compose_config = get_config_from_options(self.project_dir, config_options) @@ -312,6 +313,10 @@ class TopLevelCommand(object): print('\n'.join(service['name'] for service in compose_config.services)) return + if options['--volumes']: + print('\n'.join(volume for volume in compose_config.volumes)) + return + print(serialize_config(compose_config)) def create(self, options): diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 8366ca75e..ee895b409 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -177,6 +177,11 @@ class CLITestCase(DockerClientTestCase): result = self.dispatch(['config', '--services']) assert set(result.stdout.rstrip().split('\n')) == {'web', 'other'} + def test_config_list_volumes(self): + self.base_dir = 'tests/fixtures/v2-full' + result = self.dispatch(['config', '--volumes']) + assert set(result.stdout.rstrip().split('\n')) == {'data'} + def test_config_quiet_with_error(self): self.base_dir = None result = self.dispatch([