gh-101313: Add -h and --help arguments to the webbrowser module (gh-101374)

This commit is contained in:
Icelain 2023-03-22 17:49:52 +05:30 committed by GitHub
parent 420bbb783b
commit 3d7eb66c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -0,0 +1 @@
Added -h and --help arguments to the webbrowser CLI