menu tree mockup
This commit is contained in:
parent
57543e139a
commit
02e7221149
7 changed files with 145 additions and 23 deletions
14
cli/utils.py
Normal file
14
cli/utils.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
def choose_from_list(items, label_fn):
|
||||
for i, item in enumerate(items, start=1):
|
||||
print(f"{i}. {label_fn(item)}")
|
||||
print("0. Back")
|
||||
|
||||
choice = input("> ").strip()
|
||||
if choice == "0":
|
||||
return None
|
||||
|
||||
try:
|
||||
return items[int(choice) - 1]
|
||||
except (ValueError, IndexError):
|
||||
print("Invalid choice")
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue