Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-101313: add -h and --help arguments to the webbrowser module #101374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Lib/webbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
if len(args) != 1:
print(usage, file=sys.stderr)
sys.exit(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added -h and --help arguments to the webbrowser CLI