Skip to content

Commit 911d19d

Browse files
authored
Merge pull request #25 from bckohan/1.0.1
1.0.1
2 parents cd9f8fd + 7494e5c commit 911d19d

File tree

8 files changed

+72
-5
lines changed

8 files changed

+72
-5
lines changed

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ Installation
9191
'django_typer',
9292
]
9393
94+
*You only need to install django_typer as an app if you want to use the shellcompletion command
95+
to enable tab-completion or if you would like django-typer to install `rich traceback rendering
96+
<https://django-typer.readthedocs.io/en/latest/howto.html#configure-rich-stack-traces>`_
97+
for you - which it does by default if rich is also installed.*
9498

9599
Basic Example
96100
-------------

django_typer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
from .types import Traceback, Verbosity, Version
101101
from .utils import _command_context, traceback_config, with_typehint
102102

103-
VERSION = (1, 0, 0)
103+
VERSION = (1, 0, 1)
104104

105105
__title__ = "Django Typer"
106106
__version__ = ".".join(str(i) for i in VERSION)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from django_typer import TyperCommand, command
2+
from django_typer import initialize as root
3+
4+
5+
class Command(TyperCommand):
6+
7+
@root(invoke_without_command=True)
8+
def handle(self, flag: bool = False):
9+
# This is the root command, it runs when we run our command without
10+
# any subcommand
11+
print(flag)
12+
13+
@command()
14+
def subcommand1(self):
15+
pass
16+
17+
@command()
18+
def subcommand2(self):
19+
pass

doc/source/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Change Log
33
==========
44

5+
v1.0.1
6+
======
7+
8+
* Fixed `shell_completion broken for click < 8.1 <https://github.com/bckohan/django-typer/issues/21>`_
9+
510
v1.0.0
611
======
712

doc/source/howto.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,27 @@ pass these options upstream to Typer_ by supplying them as keyword arguments to
348348
is undefined.
349349

350350

351-
Define Shell Completions for Parameter values
352-
----------------------------------------------
351+
Define Shell Tab Completions for Parameters
352+
-------------------------------------------
353353

354354
See the section on :ref:`defining shell completions.<define-shellcompletions>`
355355

356356

357+
Debug Shell Tab Completers
358+
--------------------------
359+
360+
See the section on :ref:`debugging shell completers.<debug-shellcompletions>`
361+
362+
363+
Extend/Override TyperCommands
364+
-----------------------------
365+
366+
You can extend typer commands simply by subclassing them. All of the normal inheritance rules
367+
apply. You can either subclass an existing command from an upstream app and leave its module the
368+
same name to extend and override the command or you can subclass and rename the module to provide
369+
an adapted version of the upstream command with a different name.
370+
371+
357372
.. _configure-rich-exception-tracebacks:
358373

359374
Configure rich_ Stack Traces

doc/source/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ BaseCommand functionality is preserved, so that TyperCommand can be a drop in re
4949
'django_typer',
5050
]
5151
52+
*You only need to install django_typer as an app if you want to use the shellcompletion command
53+
to enable tab-completion or if you would like django-typer to install*
54+
:ref:`rich traceback rendering <configure-rich-exception-tracebacks>` *for you - which it does by
55+
default if rich is also installed.*
5256

5357
:big:`Basic Example`
5458

doc/source/shell_completion.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,23 @@ Django_ app labels like this:
211211

212212
See the :class:`~django_typer.completers.ModelObjectCompleter` for a completer that works
213213
for many Django_ model field types.
214+
215+
216+
.. _debug-shellcompletions:
217+
218+
Debugging Tab Completers
219+
========================
220+
221+
Debugging tab completion code can be tricky because when invoked in situ in the shell the completer
222+
code is run as a subprocess and it's output is captured by the shell. This means you can't set a
223+
breakpoint and enter into the debugger easily.
224+
225+
To help with this django-typer_ provides a debug mode that will enter into the tab-completion logic
226+
flow. Use the :class:`shellcompletion <django_typer.management.commands.shellcompletion.Command>`
227+
:func:`~django_typer.management.commands.shellcompletion.Command.complete` command, to pass the
228+
command line string that you would like to debug. For example:
229+
230+
.. code-block:: bash
231+
232+
./manage.py shellcompletion complete "mycommand --"
233+

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-typer"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
description = "Use Typer to define the CLI for your Django management commands."
55
authors = ["Brian Kohan <[email protected]>"]
66
license = "MIT"
@@ -42,7 +42,7 @@ exclude = ["django_typer/tests", "django_typer/examples", "django_typer/locale"]
4242
[tool.poetry.dependencies]
4343
python = ">=3.8,<4.0"
4444
Django = ">=3.2,<6.0"
45-
click = "^8.0.0"
45+
click = "^8.1.0"
4646

4747
# typer's release history is full of breaking changes for minor versions
4848
# given the reliance on some of its private internals we peg the typer

0 commit comments

Comments
 (0)