mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 16:53:36 +05:00
refactor: use 1-based indexing for moonraker instance selection
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -58,11 +58,17 @@ def run_moonraker_removal(
|
|||||||
def select_instances_to_remove(
|
def select_instances_to_remove(
|
||||||
instances: List[Moonraker],
|
instances: List[Moonraker],
|
||||||
) -> Union[List[Moonraker], None]:
|
) -> Union[List[Moonraker], None]:
|
||||||
print_instance_overview(instances, show_index=True, show_select_all=True)
|
start_index = 1
|
||||||
|
options = [str(i + start_index) for i in range(len(instances))]
|
||||||
options = [str(i) for i in range(len(instances))]
|
|
||||||
options.extend(["a", "A", "b", "B"])
|
options.extend(["a", "A", "b", "B"])
|
||||||
|
instance_map = {options[i]: instances[i] for i in range(len(instances))}
|
||||||
|
|
||||||
|
print_instance_overview(
|
||||||
|
instances,
|
||||||
|
start_index=start_index,
|
||||||
|
show_index=True,
|
||||||
|
show_select_all=True,
|
||||||
|
)
|
||||||
selection = get_selection_input("Select Moonraker instance to remove", options)
|
selection = get_selection_input("Select Moonraker instance to remove", options)
|
||||||
|
|
||||||
instances_to_remove = []
|
instances_to_remove = []
|
||||||
@@ -71,8 +77,7 @@ def select_instances_to_remove(
|
|||||||
elif selection == "a".lower():
|
elif selection == "a".lower():
|
||||||
instances_to_remove.extend(instances)
|
instances_to_remove.extend(instances)
|
||||||
else:
|
else:
|
||||||
instance = instances[int(selection)]
|
instances_to_remove.append(instance_map[selection])
|
||||||
instances_to_remove.append(instance)
|
|
||||||
|
|
||||||
return instances_to_remove
|
return instances_to_remove
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user