]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101313: Add -h and --help arguments to the webbrowser module (gh-101374)
authorIcelain <xerneas965@gmail.com>
Wed, 22 Mar 2023 12:19:52 +0000 (17:49 +0530)
committerGitHub <noreply@github.com>
Wed, 22 Mar 2023 12:19:52 +0000 (21:19 +0900)
Lib/webbrowser.py
Misc/NEWS.d/next/Library/2023-01-27-14-51-07.gh-issue-101313.10AEXh.rst [new file with mode: 0644]

index a56ff33dbbdc699e43ddbde681a4be489e65dc5a..4336597e68f625e81a28a67690884a1477a59aad 100755 (executable)
@@ -713,11 +713,12 @@ if sys.platform == 'darwin':
 
 def main():
     import getopt
-    usage = """Usage: %s [-n | -t] url
+    usage = """Usage: %s [-n | -t | -h] url
     -n: open new window
-    -t: open new tab""" % sys.argv[0]
+    -t: open new tab
+    -h, --help: show help""" % sys.argv[0]
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'ntd')
+        opts, args = getopt.getopt(sys.argv[1:], 'ntdh',['help'])
     except getopt.error as msg:
         print(msg, file=sys.stderr)
         print(usage, file=sys.stderr)
@@ -726,6 +727,9 @@ def main():
     for o, a in opts:
         if o == '-n': new_win = 1
         elif o == '-t': new_win = 2
+        elif o == '-h' or o == '--help': 
+            print(usage, file=sys.stderr)
+            sys.exit()
     if len(args) != 1:
         print(usage, file=sys.stderr)
         sys.exit(1)
diff --git a/Misc/NEWS.d/next/Library/2023-01-27-14-51-07.gh-issue-101313.10AEXh.rst b/Misc/NEWS.d/next/Library/2023-01-27-14-51-07.gh-issue-101313.10AEXh.rst
new file mode 100644 (file)
index 0000000..63d0a72
--- /dev/null
@@ -0,0 +1 @@
+Added -h and --help arguments to the webbrowser CLI