Selaa lähdekoodia

Add --volumes flag to config command

Closes #3609

Signed-off-by: Evan Shaw <[email protected]>
Evan Shaw 8 vuotta sitten
vanhempi
sitoutus
d67261f26e
2 muutettua tiedostoa jossa 10 lisäystä ja 0 poistoa
  1. 5 0
      compose/cli/main.py
  2. 5 0
      tests/acceptance/cli_test.py

+ 5 - 0
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):

+ 5 - 0
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([