-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_employee_user.py
executable file
·83 lines (72 loc) · 2.52 KB
/
create_employee_user.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import re
import subprocess
def format_input():
"""
Collects user input for email, TIN, profile, practice group,
Okta verification skip, and override existing options.
Formats the input into a command-line argument string.
Includes validation for email, TIN, and profile selection.
Practice group is optional, and an empty value is included in the output.
Copies the formatted string to the clipboard using pbcopy (macOS).
"""
while True:
email = input("Enter your email: ")
if re.match(r"[^@]+@[^@]+\.[^@]+", email): # Basic email format check
break
else:
print("Invalid email format. Please try again.")
while True:
tin = input("Enter your TIN (9 digits): ")
if tin.isdigit() and len(tin) == 9:
break
else:
print("Invalid TIN. Please enter exactly 9 digits.")
print("Select a profile from the following list:")
profiles = [
"ACCESS_PROFILE_CSA",
"ACCESS_PROFILE_CSM",
"ACCESS_PROFILE_PRODUCT",
"ACCESS_PROFILE_ENGINEERING",
"ACCESS_PROFILE_DS_ANALYTICS",
"ACCESS_PROFILE_TECH_LEAD",
"ACCESS_PROFILE_QA",
"ACCESS_PROFILE_PRODUCT_SUCCESS",
"ACCESS_PROFILE_CLINICAL",
]
for i, profile in enumerate(profiles):
print(f"{i+1}. {profile}")
while True:
try:
selected_profile_index = (
int(input("Enter the number of your selected profile: ")) - 1
)
if 0 <= selected_profile_index < len(profiles):
selected_profile = profiles[selected_profile_index]
break
else:
print("Invalid profile selection. Please enter a number from the list.")
except ValueError:
print("Invalid input. Please enter a number.")
practice_group = input("Enter your practice group (optional): ")
skip_okta_verify = input("Skip Okta verify? (y/n): ").lower() == "y"
override_existing = input("Override existing? (y/n): ").lower() == "y"
# Build the formatted string
formatted_string = (
f"--email={email} "
f"--tin={tin} "
f"--access_profile={selected_profile} "
f'--practice_group="{practice_group}"'
)
if skip_okta_verify:
formatted_string += " --skip_okta_verify"
if override_existing:
formatted_string += " --override_existing"
print(formatted_string)
# Copy to clipboard using pbcopy (macOS)
process = subprocess.Popen(
"pbcopy", env={"LANG": "en_US.UTF-8"}, stdin=subprocess.PIPE
)
process.communicate(formatted_string.encode("utf-8"))
print("Formatted string copied to clipboard!")
if __name__ == "__main__":
format_input()