6969import typing as t
7070from copy import deepcopy
7171from importlib import import_module
72+ from pathlib import Path
7273from types import MethodType , SimpleNamespace
7374
7475import click
@@ -1846,7 +1847,16 @@ def create_parser( # pyright: ignore[reportIncompatibleMethodOverride]
18461847 :param subcommand: the name of the django command
18471848 """
18481849 with self :
1849- return TyperParser (self , get_usage_script (prog_name ), subcommand )
1850+ if getattr (self , "_called_from_command_line" , False ):
1851+ script = get_usage_script (prog_name )
1852+ if isinstance (script , Path ):
1853+ prog_name = str (script )
1854+ if not str (prog_name ).startswith ((".." , "/" , "." )):
1855+ prog_name = f"./{ prog_name } "
1856+ else :
1857+ prog_name = str (script )
1858+
1859+ return TyperParser (self , prog_name , subcommand )
18501860
18511861 def print_help (self , prog_name : str , subcommand : str , * cmd_path : str ):
18521862 """
@@ -1859,7 +1869,7 @@ def print_help(self, prog_name: str, subcommand: str, *cmd_path: str):
18591869 typer/click have different helps for each subgroup or subcommand.
18601870 """
18611871 with self :
1862- TyperParser ( self , prog_name , subcommand ).print_help (* cmd_path )
1872+ self . create_parser ( prog_name , subcommand ).print_help (* cmd_path )
18631873
18641874 def __call__ (self , * args , ** kwargs ):
18651875 """
0 commit comments