|
15 | 15 | from rich.prompt import Prompt |
16 | 16 | from rich.prompt import Confirm |
17 | 17 | import webbrowser |
18 | | -def greet(): |
| 18 | + |
| 19 | + |
| 20 | +def _init(show_messages=False): |
19 | 21 | """ |
20 | | - shows Greeting Texts |
21 | | - :return: None |
| 22 | + - initializes the pytm data store. |
22 | 23 | """ |
23 | | - console.print("\n\033[1m✨ PyTM ✨\033[0m ") |
24 | | - console.print(f"CLI V- {__version__}") |
25 | | - console.print("\033[1m----------------\033[0m") |
26 | | - console.print("\nTry 'pytm --help' for usage information.\n\n") |
| 24 | + messages = [] |
| 25 | + messages.append("[green on white]Initializing pytm-data.\n") |
| 26 | + try: |
| 27 | + os.makedirs(data_folder) |
| 28 | + messages.append(f"Created data folder: {data_folder}") |
| 29 | + except: |
| 30 | + messages.append(f"Data folder already exists: {data_folder}") |
| 31 | + if not os.path.exists(data_filepath): |
| 32 | + init_data(data_filepath) |
| 33 | + messages.append(f"Created data file: {data_filepath}") |
| 34 | + else: |
| 35 | + messages.append(f"Data file already exists: {data_filepath}") |
| 36 | + |
| 37 | + if not os.path.exists(state_filepath): |
| 38 | + init_data(state_filepath, {CURRENT_PROJECT: "", CURRENT_TASK: ""}) |
| 39 | + messages.append(f"Created state file: {state_filepath}") |
| 40 | + else: |
| 41 | + messages.append(f"State file already exists: {state_filepath}") |
| 42 | + |
| 43 | + if show_messages: |
| 44 | + for message in messages: |
| 45 | + console.print(message) |
27 | 46 |
|
28 | 47 |
|
29 | 48 | def print_version(ctx, param, value): |
@@ -57,33 +76,18 @@ def cli(): |
57 | 76 | PyTM - CLI |
58 | 77 | docs: https://pytm.rtfd.org |
59 | 78 | """ |
60 | | - # greet() |
| 79 | + _init() |
| 80 | + |
61 | 81 |
|
62 | 82 | @click.command() |
63 | 83 | def init(): |
64 | | - """ |
65 | | - - initializes the pytm data store. |
66 | | - """ |
67 | | - console.print("[green on white]Initializing pytm-data.\n") |
68 | | - try: |
69 | | - os.makedirs(data_folder) |
70 | | - console.print(f"Created data folder: {data_folder}") |
71 | | - except: |
72 | | - console.print(f"Data folder already exists: {data_folder}") |
73 | | - if os.path.exists(data_filepath): |
74 | | - console.print(f"Data file already exists: {data_filepath}") |
75 | | - else: |
76 | | - init_data(data_filepath) |
77 | | - console.print(f"Created data file: {data_filepath}") |
78 | | - console.print("Done.") |
79 | | - if os.path.exists(state_filepath): |
80 | | - console.print(f"State file already exists: {state_filepath}") |
81 | | - else: |
82 | | - init_data(state_filepath, {CURRENT_PROJECT: "", CURRENT_TASK: ""}) |
83 | | - console.print(f"Created state file: {state_filepath}") |
84 | | - console.print("Done.") |
| 84 | + console.print("[green on white]\nDone.") |
| 85 | + console.print(f"PyTM Data is stored in: {data_folder}") |
| 86 | + console.print(f"Data file: {data_filepath}") |
| 87 | + console.print(f"State file: {state_filepath}") |
85 | 88 | console.print("\n[bold blue i on white]You also might want to run: `pytm config user` to configure default user data.[/bold blue i on white]") |
86 | 89 |
|
| 90 | + |
87 | 91 | @click.command() |
88 | 92 | def show(): |
89 | 93 | """ |
|
0 commit comments