@@ -91,7 +91,7 @@ Define Multiple Subcommands
91
91
92
92
Commands with a single executable function should simply implement handle(), but if you would
93
93
like have multiple subcommands you can define any number of functions decorated with
94
- :func: `~django_typer.command ` or :func: `~django_typer.Typer.command `:
94
+ :func: `~django_typer.management. command ` or :func: `~django_typer.management .Typer.command `:
95
95
96
96
.. tabs ::
97
97
@@ -196,8 +196,8 @@ Lets look at the help output:
196
196
Define Groups of Commands
197
197
-------------------------
198
198
199
- Any depth of command tree can be defined. Use the :func: `~django_typer.group ` or
200
- :meth: `~django_typer.Typer.add_typer ` decorator to define a group of subcommands:
199
+ Any depth of command tree can be defined. Use the :func: `~django_typer.management. group ` or
200
+ :meth: `~django_typer.management. Typer.add_typer ` decorator to define a group of subcommands:
201
201
202
202
203
203
.. tabs ::
@@ -225,8 +225,8 @@ Define an Initialization Callback
225
225
---------------------------------
226
226
227
227
You can define an initializer function that takes arguments _ and options _ that will be invoked
228
- before your handle() command or subcommands using the :func: `~django_typer.initialize ` decorator.
229
- This is like defining a group at the command root and is an extension of the
228
+ before your handle() command or subcommands using the :func: `~django_typer.management. initialize `
229
+ decorator. This is like defining a group at the command root and is an extension of the
230
230
`typer callback mechanism <https://typer.tiangolo.com/tutorial/commands/callback/ >`_.
231
231
232
232
@@ -264,11 +264,11 @@ This is like defining a group at the command root and is an extension of the
264
264
Call Commands from Code
265
265
-----------------------
266
266
267
- There are two options for invoking a :class: `~django_typer.TyperCommand ` from code without spawning
268
- off a subprocess. The first is to use Django _'s builtin call_command _ function. This function will
269
- work exactly as it does for normal BaseCommand _ derived commands. django-typer _ however adds
270
- another mechanism that can be more efficient, especially if your options and arguments are already
271
- of the correct type and require no parsing:
267
+ There are two options for invoking a :class: `~django_typer.management. TyperCommand ` from code
268
+ without spawning off a subprocess. The first is to use Django _'s builtin call_command _ function.
269
+ This function will work exactly as it does for normal BaseCommand _ derived commands. django-typer _
270
+ however adds another mechanism that can be more efficient, especially if your options and
271
+ arguments are already of the correct type and require no parsing:
272
272
273
273
Say we have this command, called ``mycommand ``:
274
274
@@ -303,8 +303,8 @@ Say we have this command, called ``mycommand``:
303
303
The rule of thumb is this:
304
304
305
305
- Use call_command _ if your options and arguments need parsing.
306
- - Use :func: `~django_typer.get_command ` and invoke the command functions directly if your
307
- options and arguments are already of the correct type.
306
+ - Use :func: `~django_typer.management. get_command ` and invoke the command functions directly if
307
+ your options and arguments are already of the correct type.
308
308
309
309
If the second argument is a type, static type checking will assume the return value of get_command
310
310
to be of that type:
@@ -325,7 +325,7 @@ You may also fetch a subcommand function directly by passing its path:
325
325
326
326
.. tip ::
327
327
328
- Also refer to the :func: `~django_typer.get_command ` docs and :ref: `here <default_cmd >`
328
+ Also refer to the :func: `~django_typer.management. get_command ` docs and :ref: `here <default_cmd >`
329
329
and :ref: `here <multi_commands >` for the nuances of calling commands when handle() is and is
330
330
not implemented.
331
331
@@ -335,15 +335,15 @@ You may also fetch a subcommand function directly by passing its path:
335
335
Change Default Django Options
336
336
-----------------------------
337
337
338
- :class: `~django_typer.TyperCommand ` classes preserve all of the functionality of BaseCommand _ derivatives.
338
+ :class: `~django_typer.management. TyperCommand ` classes preserve all of the functionality of BaseCommand _ derivatives.
339
339
This means that you can still use class members like `suppressed_base_arguments
340
340
<https://docs.djangoproject.com/en/5.0/howto/custom-management-commands/#django.core.management.BaseCommand.suppressed_base_arguments> `_
341
341
to suppress default options.
342
342
343
- By default :class: `~django_typer.TyperCommand ` suppresses ``--verbosity ``. You can add it back by
344
- setting ``suppressed_base_arguments `` to an empty list. If you want to use verbosity you can
345
- simply redefine it or use one of django-typer _'s :ref: `provided type hints <types >` for the default
346
- BaseCommand _ options:
343
+ By default :class: `~django_typer.management. TyperCommand ` suppresses ``--verbosity ``. You can add
344
+ it back by setting ``suppressed_base_arguments `` to an empty list. If you want to use verbosity you
345
+ can simply redefine it or use one of django-typer _'s :ref: `provided type hints <types >` for the
346
+ default BaseCommand _ options:
347
347
348
348
.. tabs ::
349
349
@@ -366,9 +366,9 @@ Configure Typer_ Options
366
366
------------------------
367
367
368
368
Typer _ apps can be configured using a number of parameters. These parameters are usually passed
369
- to the :class: `~django_typer.Typer ` class constructor when the application is created.
369
+ to the :class: `~django_typer.management. Typer ` class constructor when the application is created.
370
370
django-typer _ provides a way to pass these options upstream to Typer _ by supplying them as keyword
371
- arguments to the :class: `~django_typer.TyperCommand ` class inheritance:
371
+ arguments to the :class: `~django_typer.management. TyperCommand ` class inheritance:
372
372
373
373
.. tabs ::
374
374
@@ -398,9 +398,9 @@ arguments to the :class:`~django_typer.TyperCommand` class inheritance:
398
398
399
399
.. tip ::
400
400
401
- See :class: `~django_typer.TyperCommandMeta ` or :class: ` ~django_typer.Typer ` for a list of
402
- available parameters. Also refer to the ` Typer docs < https://typer.tiangolo.com >`_ for more
403
- details.
401
+ See :class: `~django_typer.management. TyperCommandMeta ` or
402
+ :class: ` ~django_typer.management.Typer ` for a list of available parameters. Also refer to the
403
+ ` Typer docs < https://typer.tiangolo.com >`_ for more details.
404
404
405
405
406
406
Define Shell Tab Completions for Parameters
@@ -658,8 +658,8 @@ Document Commands w/Sphinx
658
658
sphinxcontrib-typer _ can be used to render your rich helps to Sphinx docs and is used extensively
659
659
in this documentation.
660
660
661
- For example, to document a :class: `~django_typer.TyperCommand ` with sphinxcontrib-typer, you would
662
- do something like this:
661
+ For example, to document a :class: `~django_typer.management. TyperCommand ` with sphinxcontrib-typer,
662
+ you would do something like this:
663
663
664
664
.. code-block :: rst
665
665
@@ -698,17 +698,18 @@ There are no unbreakable rules about how you should print output from your comma
698
698
You could use loggers, normal print statements or the BaseCommand _ stdout and
699
699
stderr output wrappers. Django advises the use of ``self.stdout.write `` because the
700
700
stdout and stderr streams can be configured by calls to call_command _ or
701
- :func: `~django_tyoer .get_command ` which allows you to easily grab output from your
701
+ :func: `~django_typer.management .get_command ` which allows you to easily grab output from your
702
702
commands for testing. Using the command's configured stdout and stderr
703
703
output wrappers also means output will respect the ``--force-color `` and ``--no-color ``
704
704
parameters.
705
705
706
706
Typer _ and click _ provide `echo and secho <https://typer.tiangolo.com/tutorial/printing/ >`_
707
707
functions that automatically handle byte to string conversions and offer simple styling
708
- support. :class: `~django_typer.TyperCommand ` provides :meth: `~django_typer.TyperCommand.echo ` and
709
- :meth: `~django_typer.TyperCommand.secho ` wrapper functions for the Typer _ echo/secho
710
- functions. If you wish to use Typer _'s echo you should use these wrapper functions because
711
- they honor the command's ``--force-color `` and ``--no-color `` flags and the configured stdout/stderr
708
+ support. :class: `~django_typer.management.TyperCommand ` provides
709
+ :meth: `~django_typer.management.TyperCommand.echo ` and
710
+ :meth: `~django_typer.management.TyperCommand.secho ` wrapper functions for the Typer _ echo/secho
711
+ functions. If you wish to use Typer _'s echo you should use these wrapper functions because they
712
+ honor the command's ``--force-color `` and ``--no-color `` flags and the configured stdout/stderr
712
713
streams:
713
714
714
715
.. tabs ::
0 commit comments