Get user's project selection. Returns: Tuple of (name, path) for the selected project, or None if cancelled.
(projects: list[tuple[str, Path]])
| 108 | |
| 109 | |
| 110 | def get_project_choice(projects: list[tuple[str, Path]]) -> tuple[str, Path] | None: |
| 111 | """Get user's project selection. |
| 112 | |
| 113 | Returns: |
| 114 | Tuple of (name, path) for the selected project, or None if cancelled. |
| 115 | """ |
| 116 | while True: |
| 117 | choice = input("Select project number: ").strip().lower() |
| 118 | |
| 119 | if choice == 'b': |
| 120 | return None |
| 121 | |
| 122 | try: |
| 123 | idx = int(choice) - 1 |
| 124 | if 0 <= idx < len(projects): |
| 125 | return projects[idx] |
| 126 | print(f"Please enter a number between 1 and {len(projects)}") |
| 127 | except ValueError: |
| 128 | print("Invalid input. Enter a number or 'b' to go back.") |
| 129 | |
| 130 | |
| 131 | def get_new_project_info() -> tuple[str, Path] | None: |