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}")
|
||||
return None
|
||||
|
||||
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
|
||||
# If too many datasets, ask for manual input
|
||||
if len(datasets) > 100:
|
||||
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:
|
||||
dataset = input(f"\n{Colors.BOLD}Enter dataset name: {Colors.ENDC}").strip()
|
||||
if not dataset:
|
||||
return None
|
||||
|
||||
# Check if dataset exists
|
||||
success, _ = self.run_command(f"zfs list {dataset}")
|
||||
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]:
|
||||
"""Interactive schedule selection"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user