-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path__main__.py
More file actions
56 lines (47 loc) · 2 KB
/
Copy path__main__.py
File metadata and controls
56 lines (47 loc) · 2 KB
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
from art import text2art
import argparse
import sys
from splitcli.splitio_selectors import split_selectors, segment_selectors, metric_selectors, organization_selectors
from splitcli.accounts import signup, user, signin
from splitcli.ux import menu, text
from splitcli import config
def initial_prompt():
# Infinite loop is stopped by exit option
while True:
current_user = user.get_user()
if current_user is not None:
knownUserPrompt(current_user)
else:
newUserPrompt()
def knownUserPrompt(user):
menu.info_message(text2art(f"Hi {user.firstname}!!!"))
options = [
{"option_name": "Manage Splits", "operation": split_selectors.manage_splits},
{"option_name": "Manage Segments", "operation": segment_selectors.manage_segments},
# {"option_name": "Manage Metrics", "operation": metric_selectors.manage_metrics},
# {"option_name": "Manage Organization", "operation": organization_selectors.manage_organization},
{"option_name": "Log Out", "operation": lambda: user.delete()},
{"option_name": "Exit", "operation": exit}
]
title = "Select"
menu.select_operation(title, options)
def newUserPrompt():
menu.info_message(text2art(f"Welcome to Split!"))
options = [
{"option_name": "No, I need to create an account",
"operation": lambda: signup.create_account()},
{"option_name": "Yes, take me to sign in", "operation": lambda: signin.sign_in()},
{"option_name": "Exit", "operation": exit}
]
title = f"Do you have an existing account?"
menu.select_operation(title, options)
def main():
major_required = 3
minor_required = 6
if sys.version_info.major < major_required or sys.version_info.minor < minor_required:
menu.error_message(
f"Minimum version requirement is: {major_required}.{minor_required}. Your version is: {sys.version_info.major}.{sys.version_info.minor}")
exit()
menu.print_logo()
initial_prompt()
main()