From 9181badf5ca435e530652a44ea18b2cd7c87b952 Mon Sep 17 00:00:00 2001 From: icelain Date: Fri, 27 Jan 2023 19:58:12 +0530 Subject: [PATCH 1/3] added -h and --help arguments --- Lib/webbrowser.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 44974d433b4696..ad969e3e9f7f2d 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -709,11 +709,12 @@ def open(self, url, new=0, autoraise=True): 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) @@ -722,6 +723,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(1) if len(args) != 1: print(usage, file=sys.stderr) sys.exit(1) From 8eda250ac89e49b1355cf1d2aea458bcf7a52a63 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 27 Jan 2023 14:51:08 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-01-27-14-51-07.gh-issue-101313.10AEXh.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-01-27-14-51-07.gh-issue-101313.10AEXh.rst 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 index 00000000000000..63d0a7286920a4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-01-27-14-51-07.gh-issue-101313.10AEXh.rst @@ -0,0 +1 @@ +Added -h and --help arguments to the webbrowser CLI From d9346d11bb4ce0993168b0e72bfe7b09ba2225fc Mon Sep 17 00:00:00 2001 From: Icelain Date: Wed, 22 Feb 2023 16:17:39 +0530 Subject: [PATCH 3/3] Update Lib/webbrowser.py Co-authored-by: Dong-hee Na --- Lib/webbrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index ad969e3e9f7f2d..d2e9f38d271f50 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -725,7 +725,7 @@ def main(): elif o == '-t': new_win = 2 elif o == '-h' or o == '--help': print(usage, file=sys.stderr) - sys.exit(1) + sys.exit() if len(args) != 1: print(usage, file=sys.stderr) sys.exit(1)