Repository: click-contrib/click-aliases

Issue:
Broken with click 7
https://travis-ci.org/jayvdb/click-aliases/jobs/568251511
```
runner = <click.testing.CliRunner object at 0x7fb65f97a550>
    def test_cli(runner):
        result = runner.invoke(cli)
>       assert result.output == TEST_CLI
E       AssertionError: assert 'Usage: cli [... ship (boat)\n' == 'Usage: cli [O...ages ships.\n'
E         Skipping 116 identical leading characters in diff, use -v to show
E         - ine (bomb)
E         -   ship (boat)
E         + ine (bomb)  Manages mines.
E         +   ship (boat)  Manages ships.
tests/test_naval.py:88: AssertionError

________________________________ test_ship_help ________________________________
runner = <click.testing.CliRunner object at 0x7fb65f97b110>

    def test_ship_help(runner):
        for cmd in ['ship', 'boat']:
            result = runner.invoke(cli, [cmd])
>           assert result.output == TEST_SHIP_HELP.format(cmd=cmd)
E           AssertionError: assert 'Usage: cli s...shoot (fire)\n' == 'Usage: cli sh...ire to X,Y.\n'
E             Skipping 134 identical leading characters in diff, use -v to show
E             - ,navigate)
E             -   new (add,build,create)
E             -   shoot (fire)
E             + ,navigate)   Moves SHIP to the new location X,Y.
E             +   new (add,build,create)  Creates a new ship.
E             +   shoot (fire)            Makes SHIP fire to X,Y.
```

Comments:

Patch:
diff --git a/.travis.yml b/.travis.yml
index 6144ff7..d4504af 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,6 +18,8 @@ install:
 script:
   - flake8 click_aliases examples tests setup.py -v --show-source
   - py.test tests --cov click_aliases --cov-report term-missing
+  - pip install 'click>6,<7'
+  - py.test tests --cov click_aliases --cov-report term-missing --cov-append
 
 after_success:
   - coveralls
diff --git a/click_aliases/__init__.py b/click_aliases/__init__.py
index 32e1f08..b49b0c8 100644
--- a/click_aliases/__init__.py
+++ b/click_aliases/__init__.py
@@ -5,6 +5,8 @@
 
 import click
 
+_click7 = click.__version__[0] >= '7'
+
 
 class ClickAliasedGroup(click.Group):
     def __init__(self, *args, **kwargs):
@@ -53,7 +55,13 @@ class ClickAliasedGroup(click.Group):
 
     def format_commands(self, ctx, formatter):
         rows = []
-        for sub_command in self.list_commands(ctx):
+
+        sub_commands = self.list_commands(ctx)
+
+        max_len = max(len(cmd) for cmd in sub_commands)
+        limit = formatter.width - 6 - max_len
+
+        for sub_command in sub_commands:
             cmd = self.get_command(ctx, sub_command)
             if cmd is None:
                 continue
@@ -62,8 +70,12 @@ class ClickAliasedGroup(click.Group):
             if sub_command in self._commands:
                 aliases = ','.join(sorted(self._commands[sub_command]))
                 sub_command = '{0} ({1})'.format(sub_command, aliases)
-            cmd_help = cmd.short_help or ''
+            if _click7:
+                cmd_help = cmd.get_short_help_str(limit)
+            else:
+                cmd_help = cmd.short_help or ''
             rows.append((sub_command, cmd_help))
+
         if rows:
             with formatter.section('Commands'):
                 formatter.write_dl(rows)
diff --git a/examples/foobar.py b/examples/foobar.py
index bd70402..3de5fa2 100644
--- a/examples/foobar.py
+++ b/examples/foobar.py
@@ -1,4 +1,5 @@
 import click
+
 from click_aliases import ClickAliasedGroup
 
 
diff --git a/examples/naval.py b/examples/naval.py
index 66c22f0..ba82e50 100644
--- a/examples/naval.py
+++ b/examples/naval.py
@@ -1,4 +1,5 @@
 import click
+
 from click_aliases import ClickAliasedGroup
 
 
diff --git a/tox.ini b/tox.ini
index 1011ba9..52f509b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,4 +1,10 @@
+[tox]
+toxenv = py{27,34,35,36,36}-click{6,7}
+
 [testenv]
 passenv = LANG
-deps = pytest
+deps =
+  click6: click>6,<7
+  click7: click>=7,<8
+  pytest
 commands = py.test


Test patch:
diff --git a/tests/test_basic.py b/tests/test_basic.py
index efbcbeb..077e6c0 100644
--- a/tests/test_basic.py
+++ b/tests/test_basic.py
@@ -1,6 +1,8 @@
 import click
 from click.testing import CliRunner
-from click_aliases import ClickAliasedGroup
+
+from click_aliases import ClickAliasedGroup, _click7
+
 import pytest
 
 
@@ -40,9 +42,9 @@ def test_foobar(runner):
 
 
 TEST_INVALID = """Usage: cli [OPTIONS] COMMAND [ARGS]...
-
+{}
 Error: No such command "bar".
-"""
+""".format('Try "cli --help" for help.\n' if _click7 else '')
 
 
 def test_invalid(runner):
diff --git a/tests/test_foobar.py b/tests/test_foobar.py
index c549561..fd6c4e6 100644
--- a/tests/test_foobar.py
+++ b/tests/test_foobar.py
@@ -1,6 +1,8 @@
 import click
 from click.testing import CliRunner
-from click_aliases import ClickAliasedGroup
+
+from click_aliases import ClickAliasedGroup, _click7
+
 import pytest
 
 
@@ -41,9 +43,9 @@ def test_foobar(runner):
 
 
 TEST_INVALID = """Usage: cli [OPTIONS] COMMAND [ARGS]...
-
+{}
 Error: No such command "baz".
-"""
+""".format('Try "cli --help" for help.\n' if _click7 else '')
 
 
 def test_invalid(runner):
diff --git a/tests/test_naval.py b/tests/test_naval.py
index f4d41e7..35c23ff 100644
--- a/tests/test_naval.py
+++ b/tests/test_naval.py
@@ -1,6 +1,8 @@
 import click
 from click.testing import CliRunner
+
 from click_aliases import ClickAliasedGroup
+
 import pytest