File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -206,12 +206,8 @@ def _parse_optional(self, arg_string):
206206 return result
207207
208208 # top level parser
209- prog = sys .argv [0 ]
210- if os .path .basename (prog ) == '__main__.py' :
211- # use the module name in case the script was invoked with python -m ...
212- prog = os .path .basename (os .path .dirname (prog ))
213209 parser = CustomArgumentParser (
214- prog = prog ,
210+ prog = get_prog_name () ,
215211 formatter_class = CustomFormatter ,
216212 epilog = get_environment_variables_epilog (
217213 environment_variables_group_name ))
@@ -224,6 +220,15 @@ def _parse_optional(self, arg_string):
224220 return parser
225221
226222
223+ def get_prog_name ():
224+ """Get the prog name used for the argparse parser."""
225+ prog = sys .argv [0 ]
226+ if os .path .basename (prog ) == '__main__.py' :
227+ # use the module name in case the script was invoked with python -m ...
228+ prog = os .path .basename (os .path .dirname (prog ))
229+ return prog
230+
231+
227232class CustomFormatter (argparse .RawDescriptionHelpFormatter ):
228233 """A custom formatter to maintain newlines."""
229234
You can’t perform that action at this time.
0 commit comments