Skip to content

Commit

Permalink
Added more command line arguments for runserver and runserver_plus
Browse files Browse the repository at this point in the history
- runserver:
    --skip-checks (Closes #69)
- runserver_plus:
    --print-sql
    --pdb
    --ipdb
    --pm
  • Loading branch information
oliverandrich committed Nov 16, 2023
1 parent c98ead9 commit ee19284
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
29 changes: 14 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 43 additions & 2 deletions src/django_tailwind_cli/management/commands/tailwind.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def add_arguments(self, parser: Any) -> None:
"runserver",
help="Start the Django development server and the Tailwind CLI in watch mode.",
)

runserver_parser.add_argument(
"--skip-checks",
action="store_true",
help="Skip system checks.",
)
runserver_parser.add_argument(
"addrport", nargs="?", help="Optional port number, or ipaddr:port"
)
Expand All @@ -63,7 +67,27 @@ def add_arguments(self, parser: Any) -> None:
)

runserver_plus_parser.add_argument(
"addrport", nargs="?", help="Optional port number, or ipaddr:port"
"--pdb",
action="store_true",
help="Drop into pdb shell at the start of any view.",
)

runserver_plus_parser.add_argument(
"--ipdb",
action="store_true",
help="Drop into ipdb shell at the start of any view.",
)

runserver_plus_parser.add_argument(
"--pm",
action="store_true",
help="Drop into (i)pdb shell if an exception is raised in a view.",
)

runserver_plus_parser.add_argument(
"--print-sql",
action="store_true",
help="Print SQL queries as they're executed.",
)

runserver_plus_parser.add_argument(
Expand All @@ -82,6 +106,10 @@ def add_arguments(self, parser: Any) -> None:
help="Optional SSL certificate file to use for the development server.",
)

runserver_plus_parser.add_argument(
"addrport", nargs="?", help="Optional port number, or ipaddr:port"
)

def handle(self, *_args: Any, **kwargs: Any) -> None:
"""Perform the command's actions."""

Expand Down Expand Up @@ -154,12 +182,25 @@ def runserver(self, **kwargs: Any) -> None: # pragma: no cover
if addrport := kwargs.get("addrport"):
debugserver_cmd.append(addrport)

if kwargs.get("skip_checks", False):
debugserver_cmd.append("--skip-checks")

if kwargs.get("print_sql", False):
debugserver_cmd.append("--print-sql")
if kwargs.get("pdb", False):
debugserver_cmd.append("--pdb")
if kwargs.get("ipdb", False):
debugserver_cmd.append("--ipdb")
if kwargs.get("pm", False):
debugserver_cmd.append("--pm")

if cert_file := kwargs.get("cert_file"):
debugserver_cmd.append(f"--cert-file={cert_file}")
elif cert := kwargs.get("cert"):
debugserver_cmd.append(f"--cert-file={cert}")
if key_file := kwargs.get("key_file"):
debugserver_cmd.append(f"--key-file={key_file}")

if reloader_interval := kwargs.get("reloader_interval"):
debugserver_cmd.append(f"--reloader-interval={reloader_interval}")

Expand Down

0 comments on commit ee19284

Please sign in to comment.