Repository: pallets/click (python)

Issue:
Friendly __repr__ for Command
```python
(Pdb) pp cmd
<click.core.Command object at 0x7ff869ef1550>
(Pdb) pp cmd.name
'run-gunicorn'
```
What do you think of showing the command name in the `__repr__` string, for friendlier debugging? Could be a good beginner-friendly issue!

Pull request:
Add repr for Command, Group, Option, Argument
Cherry pick #1295 to 7.x and move the repr to `BaseCommand` and `Parameter` so it applies to all core types.

Fixes #1267

Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 8beb27d..2fc1612 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -58,6 +58,9 @@ Unreleased
 -   Arguments to system calls such as the executable path passed to
     ``click.edit`` can contains spaces. :pr:`1470`
 -   Add ZSH completion autoloading and error handling. :issue:`1348`
+-   Add a repr to ``Command``, ``Group``, ``Option``, and ``Argument``,
+    showing the name for friendlier debugging. :issue:`1267`
+
 
 Version 7.0
 -----------
diff --git a/click/core.py b/click/core.py
index 95c07b0..7066cac 100644
--- a/click/core.py
+++ b/click/core.py
@@ -622,6 +622,9 @@ class BaseCommand(object):
         #: an optional dictionary with defaults passed to the context.
         self.context_settings = context_settings
 
+    def __repr__(self):
+        return "<%s %s>" % (self.__class__.__name__, self.name)
+
     def get_usage(self, ctx):
         raise NotImplementedError('Base commands cannot get usage')
 
@@ -1393,6 +1396,9 @@ class Parameter(object):
         self.envvar = envvar
         self.autocompletion = autocompletion
 
+    def __repr__(self):
+        return "<%s %s>" % (self.__class__.__name__, self.name)
+
     @property
     def human_readable_name(self):
         """Returns the human readable name of this parameter.  This is the


Test patch:
diff --git a/tests/test_basic.py b/tests/test_basic.py
index 8de6301..f800b4d 100644
--- a/tests/test_basic.py
+++ b/tests/test_basic.py
@@ -23,6 +23,24 @@ def test_basic_functionality(runner):
     assert result.exit_code == 0
 
 
+def test_repr():
+    @click.command()
+    def command():
+        pass
+
+    @click.group()
+    def group():
+        pass
+
+    @group.command()
+    def subcommand():
+        pass
+
+    assert repr(command) == '<Command command>'
+    assert repr(group) == '<Group group>'
+    assert repr(subcommand) == '<Command subcommand>'
+
+
 def test_return_values():
     @click.command()
     def cli():