File tree 1 file changed +9
-3
lines changed 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -908,7 +908,7 @@ def parse_options(args: List[str]) -> Options:
908
908
elif args [0 ] == '--include-private' :
909
909
include_private = True
910
910
elif args [0 ] in ('-h' , '--help' ):
911
- usage ()
911
+ usage (exit_nonzero = False )
912
912
else :
913
913
raise SystemExit ('Unrecognized option %s' % args [0 ])
914
914
args = args [1 :]
@@ -943,7 +943,7 @@ def default_python2_interpreter() -> str:
943
943
raise SystemExit ("Can't find a Python 2 interpreter -- please use the -p option" )
944
944
945
945
946
- def usage () -> None :
946
+ def usage (exit_nonzero : bool = True ) -> None :
947
947
usage = textwrap .dedent ("""\
948
948
usage: stubgen [--py2] [--no-import] [--doc-dir PATH]
949
949
[--search-path PATH] [-p PATH] [-o PATH]
@@ -976,7 +976,13 @@ def usage() -> None:
976
976
-h, --help print this help message and exit
977
977
""" .rstrip ())
978
978
979
- raise SystemExit (usage )
979
+ if exit_nonzero :
980
+ # The user made a mistake, so we should return with an error code
981
+ raise SystemExit (usage )
982
+ else :
983
+ # The user asked for help specifically, so we should exit with success
984
+ print (usage , file = sys .stderr )
985
+ sys .exit ()
980
986
981
987
982
988
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments