From 1bbab217d0e68367722716417fce0f2d342a449b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 22 Jan 2022 11:39:54 +0530 Subject: [PATCH] ask kitten: Always have a default choice --- kittens/ask/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kittens/ask/main.py b/kittens/ask/main.py index 05bf5d0b1..063894366 100644 --- a/kittens/ask/main.py +++ b/kittens/ask/main.py @@ -100,7 +100,7 @@ For example: y:Yes and n;red:No --default -d A default choice or text. If unspecified, it is "y" for yesno and empty for the others. If the input type is choices and the specified value is not one of the -available choices, it is empty. The default choice is selected when the user +available choices, it is the first choice. The default choice is selected when the user presses the Enter key. ''' @@ -161,7 +161,7 @@ class Choose(Handler): self.allowed = frozenset(allowed) self.response = cli_opts.default if cli_opts.type in ('yesno', 'choices') and self.response not in self.allowed: - self.response = 'y' if cli_opts.type == 'yesno' else '' + self.response = 'y' if cli_opts.type == 'yesno' else tuple(self.choices.keys())[0] def initialize(self) -> None: self.cmd.set_cursor_visible(False)