Commits

Lukasz Balcerzak committed fa9fb21

Added --list switch to show all envs

  • Participants
  • Parent commits a77eb52

Comments (0)

Files changed (3)

File tests/test_config.py

         assert tox.__version__ in stdout
         assert "imported from" in stdout
 
+    def test_listenvs(self, cmd, initproj):
+        initproj('listenvs', filedefs={
+            'tox.ini': '''
+            [tox]
+            envlist=py26,py27,py33,pypy,docs
+
+            [testenv:docs]
+            changedir = docs
+            ''',
+        })
+        result = cmd.run("tox", "-l")
+        stdout = result.stdout.str()
+        assert stdout.splitlines() == [
+            ' * py26',
+            ' * py27',
+            ' * py33',
+            ' * pypy',
+            ' * docs',
+        ]
+
     @py.test.mark.xfail("sys.version_info < (2,6)",
         reason="virtualenv3 cannot be imported")
     def test_config_specific_ini(self, tmpdir, cmd):

File tox/_cmdline.py

                 raise SystemExit(1)
         if self.config.option.showconfig:
             self.showconfig()
+        elif self.config.option.list_envs:
+            self.showenvs()
         else:
             return self.subcommand_test()
 
             self.report.line("  envdir=    %s" % envconfig.envdir)
             self.report.line("  downloadcache=%s" % envconfig.downloadcache)
 
+    def showenvs(self):
+        for env in self.config.envlist:
+            self.report.line(" * %s" % env)
+
     def info_versions(self):
         versions = ['tox-%s' % tox.__version__]
         version = py.process.cmdexec("virtualenv --version")

File tox/_config.py

         help="force recreation of virtual environments")
     parser.add_argument("args", nargs="*",
         help="additional arguments available to command positional substition")
+    parser.add_argument("-l", "--list", action="store_true", dest="list_envs",
+        help="show default envlist")
     return parser
 
 class Config: