8000 gh-101313: Add -h and --help arguments to the webbrowser module (gh-1… · python/cpython@3d7eb66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d7eb66

Browse files
authored
gh-101313: Add -h and --help arguments to the webbrowser module (gh-101374)
1 parent 420bbb7 commit 3d7eb66

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Lib/webbrowser.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,12 @@ def open(self, url, new=0, autoraise=True):
713713

714714
def main():
715715
import getopt
716-
usage = """Usage: %s [-n | -t] url
716+
usage = """Usage: %s [-n | -t | -h] url
717717
-n: open new window
718-
-t: open new tab""" % sys.argv[0]
718+
-t: open new tab
719+
-h, --help: show help""" % sys.argv[0]
719720
try:
720-
opts, args = getopt.getopt(sys.argv[1:], 'ntd')
721+
opts, args = getopt.getopt(sys.argv[1:], 'ntdh',['help'])
721722
except getopt.error as msg:
722723
print(msg, file=sys.stderr)
723724
print(usage, file=sys.stderr)
@@ -726,6 +727,9 @@ def main():
726727
for o, a in opts:
727728
if o == '-n': new_win = 1
728729
elif o == '-t': new_win = 2
730+
elif o == '-h' or o == '--help':
731+
print(usage, file=sys.stderr)
732+
sys.exit()
729733
if len(args) != 1:
730734
print(usage, file=sys.stderr)
731735
sys.exit(1)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added -h and --help arguments to the webbrowser CLI

0 commit comments

Comments
 (0)
0