Skip to content

Commit e735482

Browse files
committed
Refactor a console script
1 parent 0eae9a8 commit e735482

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

console_scripts/sb_mkdir.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,42 @@
44
Usage:
55
seleniumbase mkdir [DIRECTORY_NAME]
66
Output:
7-
A new folder for running SeleniumBase scripts.
8-
Contains default config files, boilerplates, and sample tests.
7+
Creates a new folder for running SeleniumBase scripts.
8+
The new folder contains default config files,
9+
sample tests for helping new users get started, and
10+
Python boilerplates for setting up customized
11+
test frameworks.
912
"""
1013

1114
import codecs
1215
import os
1316
import sys
1417

1518

19+
def invalid_run_command():
20+
exp = (" ** mkdir **\n\n")
21+
exp += " Usage:\n"
22+
exp += " seleniumbase mkdir [DIRECTORY_NAME]\n"
23+
exp += " Example:\n"
24+
exp += " seleniumbase mkdir gui_tests\n"
25+
exp += " Output:\n"
26+
exp += " Creates a new folder for running SeleniumBase scripts.\n"
27+
exp += " The new folder contains default config files,\n"
28+
exp += " sample tests for helping new users get started, and\n"
29+
exp += " Python boilerplates for setting up customized\n"
30+
exp += " test frameworks.\n"
31+
print("")
32+
raise Exception('INVALID RUN COMMAND!\n\n%s' % exp)
33+
34+
1635
def main():
17-
expected_arg = ("[DIRECTORY_NAME]")
1836
num_args = len(sys.argv)
1937
if sys.argv[0].split('/')[-1] == "seleniumbase" or (
2038
sys.argv[0].split('\\')[-1] == "seleniumbase"):
2139
if num_args < 3 or num_args > 3:
22-
raise Exception('\n* INVALID RUN COMMAND! * Usage:\n'
23-
'"seleniumbase mkdir %s"\n' % expected_arg)
40+
invalid_run_command()
2441
else:
25-
raise Exception('\n* INVALID RUN COMMAND! * Usage:\n'
26-
'"seleniumbase mkdir %s"\n' % expected_arg)
42+
invalid_run_command()
2743
dir_name = sys.argv[num_args-1]
2844
if len(str(dir_name)) < 2:
2945
raise Exception('Directory name length must be at least 2 '

0 commit comments

Comments
 (0)