69
69
import typing as t
70
70
from copy import deepcopy
71
71
from importlib import import_module
72
+ from pathlib import Path
72
73
from types import MethodType , SimpleNamespace
73
74
74
75
import click
@@ -1846,7 +1847,16 @@ def create_parser( # pyright: ignore[reportIncompatibleMethodOverride]
1846
1847
:param subcommand: the name of the django command
1847
1848
"""
1848
1849
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 )
1850
1860
1851
1861
def print_help (self , prog_name : str , subcommand : str , * cmd_path : str ):
1852
1862
"""
@@ -1859,7 +1869,7 @@ def print_help(self, prog_name: str, subcommand: str, *cmd_path: str):
1859
1869
typer/click have different helps for each subgroup or subcommand.
1860
1870
"""
1861
1871
with self :
1862
- TyperParser ( self , prog_name , subcommand ).print_help (* cmd_path )
1872
+ self . create_parser ( prog_name , subcommand ).print_help (* cmd_path )
1863
1873
1864
1874
def __call__ (self , * args , ** kwargs ):
1865
1875
"""
0 commit comments