Skip to content

Commit 749dee5

Browse files
committed
Fix issue with console scripts "--help" / "-h" options
1 parent c0d92bd commit 749dee5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def invalid_run_command(msg=None):
4343
exp += " test frameworks.\n"
4444
if not msg:
4545
raise Exception('INVALID RUN COMMAND!\n\n%s' % exp)
46+
elif msg == "help":
47+
print("\n%s" % exp)
48+
sys.exit()
4649
else:
4750
raise Exception('INVALID RUN COMMAND!\n\n%s\n%s\n' % (exp, msg))
4851

@@ -66,7 +69,9 @@ def main():
6669

6770
command_args = sys.argv[2:]
6871
dir_name = command_args[0]
69-
if len(str(dir_name)) < 2:
72+
if dir_name == "-h" or dir_name == "--help":
73+
invalid_run_command("help")
74+
elif len(str(dir_name)) < 2:
7075
error_msg = (
7176
'Directory name length must be at least 2 characters long!')
7277
elif "/" in str(dir_name) or "\\" in str(dir_name):
@@ -85,7 +90,7 @@ def main():
8590
options = command_args[1:]
8691
for option in options:
8792
option = option.lower()
88-
if option == "help" or option == "--help":
93+
if option == "-h" or option == "--help":
8994
help_me = True
9095
elif option == "-b" or option == "--basic":
9196
basic = True

seleniumbase/console_scripts/sb_mkfile.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def invalid_run_command(msg=None):
6262
exp += ' is included.\n'
6363
if not msg:
6464
raise Exception('INVALID RUN COMMAND!\n\n%s' % exp)
65+
elif msg == "help":
66+
print("\n%s" % exp)
67+
sys.exit()
6568
else:
6669
raise Exception('INVALID RUN COMMAND!\n\n%s\n%s\n' % (exp, msg))
6770

@@ -86,7 +89,9 @@ def main():
8689

8790
command_args = sys.argv[2:]
8891
file_name = command_args[0]
89-
if not file_name.endswith(".py"):
92+
if file_name == "-h" or file_name == "--help":
93+
invalid_run_command("help")
94+
elif not file_name.endswith(".py"):
9095
error_msg = 'File name must end with ".py"!'
9196
elif "*" in file_name or len(str(file_name)) < 4:
9297
error_msg = 'Invalid file name!'
@@ -105,7 +110,7 @@ def main():
105110
options = command_args[1:]
106111
for option in options:
107112
option = option.lower()
108-
if option == "help" or option == "--help":
113+
if option == "-h" or option == "--help":
109114
help_me = True
110115
elif option == "-b" or option == "--basic":
111116
basic = True

0 commit comments

Comments
 (0)