Options: fix "toggle: random" always being True

This commit is contained in:
Fabian Dill 2022-03-31 22:09:54 +02:00 committed by Fabian Dill
parent 0fd59063d9
commit 1f16310797
1 changed files with 3 additions and 1 deletions

View File

@ -111,7 +111,9 @@ class Toggle(Option[int]):
@classmethod
def from_text(cls, text: str) -> Toggle:
if text.lower() in {"off", "0", "false", "none", "null", "no"}:
if text == "random":
return cls(random.choice(list(cls.name_lookup)))
elif text.lower() in {"off", "0", "false", "none", "null", "no"}:
return cls(0)
else:
return cls(1)