|
6 | 6 | import sys |
7 | 7 | from typing import Optional |
8 | 8 |
|
| 9 | +import readchar |
| 10 | + |
9 | 11 | from .display import DisplayFormatter |
10 | 12 | from .cache import CacheManager |
11 | 13 | from .config import ConfigManager |
|
15 | 17 | def parse_args() -> argparse.Namespace: |
16 | 18 | """Parse command-line arguments.""" |
17 | 19 | parser = argparse.ArgumentParser( |
18 | | - description="A neofetch-style CLI tool for GitHub statistics", |
| 20 | + description="A neofetch-style CLI tool for git provider statistics", |
19 | 21 | formatter_class=argparse.RawDescriptionHelpFormatter |
20 | 22 | ) |
21 | 23 |
|
@@ -203,26 +205,42 @@ def _prompt_username() -> Optional[str]: |
203 | 205 |
|
204 | 206 |
|
205 | 207 | def _prompt_provider() -> Optional[str]: |
206 | | - """Prompt user for git provider.""" |
207 | | - try: |
208 | | - print("Available git providers:") |
209 | | - print("1. GitHub") |
210 | | - print("2. GitLab") |
211 | | - print("3. Gitea/Forgejo/Codeberg") |
212 | | - print("4. Sourcehut") |
| 208 | + """Prompt user for git provider with interactive selection.""" |
| 209 | + providers = [ |
| 210 | + ('github', 'GitHub'), |
| 211 | + ('gitlab', 'GitLab'), |
| 212 | + ('gitea', 'Gitea/Forgejo/Codeberg'), |
| 213 | + ('sourcehut', 'Sourcehut') |
| 214 | + ] |
| 215 | + |
| 216 | + selected = 0 |
213 | 217 |
|
| 218 | + try: |
214 | 219 | while True: |
215 | | - choice = input("Choose your git provider (1-4): ").strip() |
216 | | - if choice == '1': |
217 | | - return 'github' |
218 | | - elif choice == '2': |
219 | | - return 'gitlab' |
220 | | - elif choice == '3': |
221 | | - return 'gitea' |
222 | | - elif choice == '4': |
223 | | - return 'sourcehut' |
224 | | - else: |
225 | | - print("Invalid choice. Please enter 1-4.") |
| 220 | + # Clear screen and print header |
| 221 | + print("\033[2J\033[H", end="") |
| 222 | + print("Choose your git provider:") |
| 223 | + print() |
| 224 | + |
| 225 | + # Print options with cursor |
| 226 | + for i, (key, name) in enumerate(providers): |
| 227 | + indicator = "●" if i == selected else "○" |
| 228 | + print(f"{indicator} {name}") |
| 229 | + |
| 230 | + print() |
| 231 | + print("Use ↑/↓ arrows, ● = selected, Enter to confirm") |
| 232 | + |
| 233 | + # Read key |
| 234 | + key = readchar.readkey() |
| 235 | + |
| 236 | + if key == readchar.key.UP: |
| 237 | + selected = (selected - 1) % len(providers) |
| 238 | + elif key == readchar.key.DOWN: |
| 239 | + selected = (selected + 1) % len(providers) |
| 240 | + elif key == readchar.key.ENTER: |
| 241 | + print() # New line after selection |
| 242 | + return providers[selected][0] |
| 243 | + |
226 | 244 | except (KeyboardInterrupt, EOFError): |
227 | 245 | print() |
228 | 246 | return None |
|
0 commit comments