summaryrefslogtreecommitdiffstats
path: root/Lib/webbrowser.py
diff options
context:
space:
mode:
authorIcelain <xerneas965@gmail.com>2023-03-22 12:19:52 (GMT)
committerGitHub <noreply@github.com>2023-03-22 12:19:52 (GMT)
commit3d7eb66c963c0c86021738271483bef27c425b17 (patch)
treecae6f95226b597a2ce89a39c05e9f157ae812df2 /Lib/webbrowser.py
parent420bbb783b43216cc897dc8914851899db37a31d (diff)
downloadcpython-3d7eb66c963c0c86021738271483bef27c425b17.zip
cpython-3d7eb66c963c0c86021738271483bef27c425b17.tar.gz
cpython-3d7eb66c963c0c86021738271483bef27c425b17.tar.bz2
gh-101313: Add -h and --help arguments to the webbrowser module (gh-101374)
Diffstat (limited to 'Lib/webbrowser.py')
-rwxr-xr-xLib/webbrowser.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index a56ff33..4336597 100755
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -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)