Coverage for types.py: 100%
20 statements
« prev ^ index » next coverage.py v7.3.4, created at 2024-01-20 17:58 +0000
« prev ^ index » next coverage.py v7.3.4, created at 2024-01-20 17:58 +0000
1"""
2Common types for command line argument specification.
3"""
5import sys
6from pathlib import Path
7from typing import Annotated, Optional
9from django.apps import AppConfig
10from django.utils.translation import gettext_lazy as _
11from typer import Option
13COMMON_PANEL = "Django"
16def print_version(context, _, value):
17 """
18 A callback to run the get_version() routine of the
19 command when --version is specified.
20 """
21 if value:
22 context.django_command.stdout.write(context.django_command.get_version())
23 sys.exit()
26Version = Annotated[
27 bool,
28 Option(
29 "--version",
30 help=_("Show program's version number and exit."),
31 callback=print_version,
32 is_eager=True,
33 rich_help_panel=COMMON_PANEL,
34 ),
35]
37Verbosity = Annotated[
38 int,
39 Option(
40 help=_(
41 "Verbosity level; 0=minimal output, 1=normal output, "
42 "2=verbose output, 3=very verbose output"
43 ),
44 show_choices=True,
45 min=0,
46 max=3,
47 rich_help_panel=COMMON_PANEL,
48 ),
49]
51Settings = Annotated[
52 str,
53 Option(
54 help=_(
55 "The Python path to a settings module, e.g. "
56 '"myproject.settings.main". If this isn\'t provided, the '
57 "DJANGO_SETTINGS_MODULE environment variable will be used."
58 ),
59 rich_help_panel=COMMON_PANEL,
60 ),
61]
63PythonPath = Annotated[
64 Optional[Path],
65 Option(
66 help=_(
67 "A directory to add to the Python path, e.g. "
68 '"/home/djangoprojects/myproject".'
69 ),
70 rich_help_panel=COMMON_PANEL,
71 ),
72]
74Traceback = Annotated[
75 bool,
76 Option(
77 "--traceback",
78 help=_("Raise on CommandError exceptions"),
79 rich_help_panel=COMMON_PANEL,
80 ),
81]
83NoColor = Annotated[
84 bool,
85 Option(
86 "--no-color",
87 help=_("Don't colorize the command output."),
88 rich_help_panel=COMMON_PANEL,
89 ),
90]
92ForceColor = Annotated[
93 bool,
94 Option(
95 "--force-color",
96 help=_("Force colorization of the command output."),
97 rich_help_panel=COMMON_PANEL,
98 ),
99]
101SkipChecks = Annotated[
102 bool,
103 Option(
104 "--skip-checks", help=_("Skip system checks."), rich_help_panel=COMMON_PANEL
105 ),
106]
109AppLabel = Annotated[
110 AppConfig,
111 Option(
112 help=_("Specifies the application configuration to use."),
113 rich_help_panel=COMMON_PANEL,
114 ),
115]