Merge pull request #3263 from twitherspoon/3191_2_help_cli_feature

Added code to support no argument help command
This commit is contained in:
Aanand Prasad 2016-04-19 12:14:24 +01:00
commit 984f839d33
2 changed files with 10 additions and 5 deletions

View File

@ -372,10 +372,14 @@ class TopLevelCommand(object):
""" """
Get help on a command. Get help on a command.
Usage: help COMMAND Usage: help [COMMAND]
""" """
handler = get_handler(cls, options['COMMAND']) if options['COMMAND']:
raise SystemExit(getdoc(handler)) subject = get_handler(cls, options['COMMAND'])
else:
subject = cls
print(getdoc(subject))
def kill(self, options): def kill(self, options):
""" """

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import os import os
import shutil import shutil
import tempfile import tempfile
from io import StringIO
import docker import docker
import py import py
@ -83,10 +84,10 @@ class CLITestCase(unittest.TestCase):
self.assertTrue(project.services) self.assertTrue(project.services)
def test_command_help(self): def test_command_help(self):
with pytest.raises(SystemExit) as exc: with mock.patch('sys.stdout', new=StringIO()) as fake_stdout:
TopLevelCommand.help({'COMMAND': 'up'}) TopLevelCommand.help({'COMMAND': 'up'})
assert 'Usage: up' in exc.exconly() assert "Usage: up" in fake_stdout.getvalue()
def test_command_help_nonexistent(self): def test_command_help_nonexistent(self):
with pytest.raises(NoSuchCommand): with pytest.raises(NoSuchCommand):