Support disabled entries

This commit is contained in:
2Shirt 2019-05-28 20:23:23 -06:00
parent 8f94a9a19c
commit a3714dec6f
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -4,6 +4,19 @@
import os
from collections import OrderedDict
# STATIC VARIABLES
COLORS = {
'CLEAR': '\033[0m',
'RED': '\033[31m',
'ORANGE': '\033[31;1m',
'GREEN': '\033[32m',
'YELLOW': '\033[33m',
'BLUE': '\033[34m',
'PURPLE': '\033[35m',
'CYAN': '\033[36m',
}
# Classes
class MenuState():
"""Class to track various parts of a menu."""
@ -61,6 +74,14 @@ class MenuState():
display_list.append('{}: {}'.format(_prefix, name))
valid_answers[_prefix] = name
# Disable entry if necessary
if details['Disabled']:
display_list[-1] = '{ORANGE}{text}{CLEAR}'.format(
text=display_list[-1],
**COLORS,
)
valid_answers.pop(_prefix)
# Show Menu and make selection
_answer = ''
while _answer.upper() not in valid_answers: