Skip to content

Commit

Permalink
Merge pull request #25 from bckohan/1.0.1
Browse files Browse the repository at this point in the history
1.0.1
  • Loading branch information
bckohan authored Feb 29, 2024
2 parents cd9f8fd + 7494e5c commit 911d19d
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ Installation
'django_typer',
]
*You only need to install django_typer as an app if you want to use the shellcompletion command
to enable tab-completion or if you would like django-typer to install `rich traceback rendering
<https://django-typer.readthedocs.io/en/latest/howto.html#configure-rich-stack-traces>`_
for you - which it does by default if rich is also installed.*

Basic Example
-------------
Expand Down
2 changes: 1 addition & 1 deletion django_typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
from .types import Traceback, Verbosity, Version
from .utils import _command_context, traceback_config, with_typehint

VERSION = (1, 0, 0)
VERSION = (1, 0, 1)

__title__ = "Django Typer"
__version__ = ".".join(str(i) for i in VERSION)
Expand Down
19 changes: 19 additions & 0 deletions django_typer/tests/test_app/management/commands/howto3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django_typer import TyperCommand, command
from django_typer import initialize as root


class Command(TyperCommand):

@root(invoke_without_command=True)
def handle(self, flag: bool = False):
# This is the root command, it runs when we run our command without
# any subcommand
print(flag)

@command()
def subcommand1(self):
pass

@command()
def subcommand2(self):
pass
5 changes: 5 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Change Log
==========

v1.0.1
======

* Fixed `shell_completion broken for click < 8.1 <https://github.com/bckohan/django-typer/issues/21>`_

v1.0.0
======

Expand Down
19 changes: 17 additions & 2 deletions doc/source/howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,27 @@ pass these options upstream to Typer_ by supplying them as keyword arguments to
is undefined.


Define Shell Completions for Parameter values
----------------------------------------------
Define Shell Tab Completions for Parameters
-------------------------------------------

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


Debug Shell Tab Completers
--------------------------

See the section on :ref:`debugging shell completers.<debug-shellcompletions>`


Extend/Override TyperCommands
-----------------------------

You can extend typer commands simply by subclassing them. All of the normal inheritance rules
apply. You can either subclass an existing command from an upstream app and leave its module the
same name to extend and override the command or you can subclass and rename the module to provide
an adapted version of the upstream command with a different name.


.. _configure-rich-exception-tracebacks:

Configure rich_ Stack Traces
Expand Down
4 changes: 4 additions & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ BaseCommand functionality is preserved, so that TyperCommand can be a drop in re
'django_typer',
]
*You only need to install django_typer as an app if you want to use the shellcompletion command
to enable tab-completion or if you would like django-typer to install*
:ref:`rich traceback rendering <configure-rich-exception-tracebacks>` *for you - which it does by
default if rich is also installed.*

:big:`Basic Example`

Expand Down
20 changes: 20 additions & 0 deletions doc/source/shell_completion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,23 @@ Django_ app labels like this:

See the :class:`~django_typer.completers.ModelObjectCompleter` for a completer that works
for many Django_ model field types.


.. _debug-shellcompletions:

Debugging Tab Completers
========================

Debugging tab completion code can be tricky because when invoked in situ in the shell the completer
code is run as a subprocess and it's output is captured by the shell. This means you can't set a
breakpoint and enter into the debugger easily.

To help with this django-typer_ provides a debug mode that will enter into the tab-completion logic
flow. Use the :class:`shellcompletion <django_typer.management.commands.shellcompletion.Command>`
:func:`~django_typer.management.commands.shellcompletion.Command.complete` command, to pass the
command line string that you would like to debug. For example:

.. code-block:: bash
./manage.py shellcompletion complete "mycommand --"
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-typer"
version = "1.0.0"
version = "1.0.1"
description = "Use Typer to define the CLI for your Django management commands."
authors = ["Brian Kohan <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -42,7 +42,7 @@ exclude = ["django_typer/tests", "django_typer/examples", "django_typer/locale"]
[tool.poetry.dependencies]
python = ">=3.8,<4.0"
Django = ">=3.2,<6.0"
click = "^8.0.0"
click = "^8.1.0"

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

0 comments on commit 911d19d

Please sign in to comment.