feat: dont list datasets if there are many
This commit is contained in:
parent
6afbddc9ce
commit
de64c6d4d5
@ -159,19 +159,40 @@ class PDGSnapshot:
|
|||||||
print(f"{Colors.RED}✗ No ZFS datasets found{Colors.ENDC}")
|
print(f"{Colors.RED}✗ No ZFS datasets found{Colors.ENDC}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
print(f"\n{Colors.BOLD}Available ZFS Datasets:{Colors.ENDC}")
|
# If too many datasets, ask for manual input
|
||||||
for i, dataset in enumerate(datasets, 1):
|
if len(datasets) > 100:
|
||||||
print(f"{Colors.CYAN}{i:2d}.{Colors.ENDC} {dataset}")
|
print(f"\n{Colors.YELLOW}Found {len(datasets)} datasets - too many to list{Colors.ENDC}")
|
||||||
|
print(f"{Colors.DIM}Tip: Use 'zfs list' to see all available datasets{Colors.ENDC}")
|
||||||
while True:
|
|
||||||
try:
|
while True:
|
||||||
choice = input(f"\n{Colors.BOLD}Select dataset (1-{len(datasets)}): {Colors.ENDC}")
|
dataset = input(f"\n{Colors.BOLD}Enter dataset name: {Colors.ENDC}").strip()
|
||||||
idx = int(choice) - 1
|
if not dataset:
|
||||||
if 0 <= idx < len(datasets):
|
return None
|
||||||
return datasets[idx]
|
|
||||||
print(f"{Colors.RED}Invalid selection{Colors.ENDC}")
|
# Check if dataset exists
|
||||||
except (ValueError, KeyboardInterrupt):
|
success, _ = self.run_command(f"zfs list {dataset}")
|
||||||
return None
|
if success:
|
||||||
|
return dataset
|
||||||
|
else:
|
||||||
|
print(f"{Colors.RED}✗ Dataset '{dataset}' not found{Colors.ENDC}")
|
||||||
|
retry = input(f"{Colors.DIM}Try again? (y/n): {Colors.ENDC}").lower()
|
||||||
|
if retry != 'y':
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
# Show numbered list for reasonable amount of datasets
|
||||||
|
print(f"\n{Colors.BOLD}Available ZFS Datasets:{Colors.ENDC}")
|
||||||
|
for i, dataset in enumerate(datasets, 1):
|
||||||
|
print(f"{Colors.CYAN}{i:2d}.{Colors.ENDC} {dataset}")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
choice = input(f"\n{Colors.BOLD}Select dataset (1-{len(datasets)}): {Colors.ENDC}")
|
||||||
|
idx = int(choice) - 1
|
||||||
|
if 0 <= idx < len(datasets):
|
||||||
|
return datasets[idx]
|
||||||
|
print(f"{Colors.RED}Invalid selection{Colors.ENDC}")
|
||||||
|
except (ValueError, KeyboardInterrupt):
|
||||||
|
return None
|
||||||
|
|
||||||
def select_schedule(self) -> Optional[str]:
|
def select_schedule(self) -> Optional[str]:
|
||||||
"""Interactive schedule selection"""
|
"""Interactive schedule selection"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user