@@ -97,29 +97,22 @@ class Command(TyperCommand):
9797 @cached_property
9898 def manage_script (self ) -> t .Union [str , Path ]:
9999 """
100- The name of the django manage command script to install autocompletion for. We do
101- not want to hardcode this as 'manage.py' because users are free to rename and implement
102- their own manage scripts! The safest way to do this is therefore to require this install
103- script to be a management command itself and then fetch the name of the script that invoked
104- it.
105-
106- Get the manage script as either the name of it as a command available from the shell's path
107- if it is or as an absolute path to it as a script if it is not a command available on the
108- path. If the script is invoked via python, a CommandError is thrown.
109-
110- Most shell's completion infrastructure works best if the commands are available on the
111- path. However, it is common for Django development to be done in a virtual environment with
112- a manage.py script being invoked directly as a script. Completion should work in this case
113- as well, but it does complicate the installation for some shell's so we must first figure
114- out which mode we are in.
115-
116- If this property returns a string the command is available as a command on the path. If it
117- returns a path the command is available as a script but is not generally available on the
118- path.
100+ Returns the name of the manage command as a string if it is available as a command
101+ on the user path. If it is a script that is not available as a command on the path
102+ it will return an absolute Path object to the script.
119103 """
104+ # We do not want to hardcode this as 'manage.py' because users are free to rename and
105+ # implement their own manage scripts! The safest way to do this is therefore to fetch
106+ # the name of the script that invoked the shellcompletion command and determine if that
107+ # script is available on the user's path or not.
108+
109+ # Most shell's completion infrastructure works best if the commands are available on the
110+ # path. However, it is common for Django development to be done in a virtual environment
111+ # with a manage.py script being invoked directly as a script. Completion should work in
112+ # this case as well, but it does complicate the installation for some shell's so we must
113+ # first figure out which mode we are in.
114+
120115 cmd_pth = Path (sys .argv [0 ])
121- # manage.py might happen to be on the current path, but it might also be installed as
122- # a command - we test it here using which to be sure
123116 if shutil .which (cmd_pth .name ):
124117 return cmd_pth .name
125118 return cmd_pth .absolute ()
@@ -606,6 +599,3 @@ def noop(self):
606599 has no use other than to avoid any potential attribute access errors when we spoof
607600 completion logic
608601 """
609- import ipdb
610-
611- ipdb .set_trace ()
0 commit comments