mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 09:44:59 +00:00
fix: Improve input validation and handling for yes/no/all/skip options
This commit is contained in:
parent
9bc1788003
commit
f85db450a1
1 changed files with 20 additions and 20 deletions
40
aider/io.py
40
aider/io.py
|
@ -148,7 +148,7 @@ class InputOutput:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
pretty=True,
|
pretty=True,
|
||||||
yes=False,
|
yes=None,
|
||||||
input_history_file=None,
|
input_history_file=None,
|
||||||
chat_history_file=None,
|
chat_history_file=None,
|
||||||
input=None,
|
input=None,
|
||||||
|
@ -379,16 +379,15 @@ class InputOutput:
|
||||||
):
|
):
|
||||||
self.num_user_asks += 1
|
self.num_user_asks += 1
|
||||||
|
|
||||||
valid_responses = ["y", "n", ""]
|
valid_responses = "yn"
|
||||||
if group and not explicit_yes_required:
|
options = " (Y)es/(N)o"
|
||||||
valid_responses.extend(["a", "s"])
|
|
||||||
|
|
||||||
question += " (Y)es/(N)o"
|
|
||||||
if group:
|
if group:
|
||||||
if not explicit_yes_required:
|
if not explicit_yes_required:
|
||||||
question += "/(A)ll"
|
options += "/(A)ll"
|
||||||
question += "/(S)kip all"
|
valid_responses += "a"
|
||||||
question += " [Y]: "
|
options += "/(S)kip all"
|
||||||
|
valid_responses += "s"
|
||||||
|
question += options + " [Y]: "
|
||||||
|
|
||||||
if subject:
|
if subject:
|
||||||
self.tool_output()
|
self.tool_output()
|
||||||
|
@ -411,11 +410,7 @@ class InputOutput:
|
||||||
return True
|
return True
|
||||||
return text.lower()[0] in valid_responses
|
return text.lower()[0] in valid_responses
|
||||||
|
|
||||||
error_message = (
|
error_message = f"Please answer one of {options}"
|
||||||
"Please answer Yes or No."
|
|
||||||
if explicit_yes_required or group is None
|
|
||||||
else "Please answer Yes, No, All, or Skip all."
|
|
||||||
)
|
|
||||||
validator = Validator.from_callable(
|
validator = Validator.from_callable(
|
||||||
is_valid_response,
|
is_valid_response,
|
||||||
error_message=error_message,
|
error_message=error_message,
|
||||||
|
@ -426,7 +421,7 @@ class InputOutput:
|
||||||
res = "n" if explicit_yes_required else "y"
|
res = "n" if explicit_yes_required else "y"
|
||||||
elif self.yes is False:
|
elif self.yes is False:
|
||||||
res = "n"
|
res = "n"
|
||||||
elif group and group.preference and not explicit_yes_required:
|
elif group and group.preference:
|
||||||
res = group.preference
|
res = group.preference
|
||||||
else:
|
else:
|
||||||
res = prompt(
|
res = prompt(
|
||||||
|
@ -438,12 +433,17 @@ class InputOutput:
|
||||||
res = "y" # Default to Yes if no input
|
res = "y" # Default to Yes if no input
|
||||||
|
|
||||||
res = res.lower()[0]
|
res = res.lower()[0]
|
||||||
is_yes = res in ("y", "a")
|
|
||||||
is_all = res == "a" and group is not None and not explicit_yes_required
|
|
||||||
is_skip = res == "s" and group is not None and not explicit_yes_required
|
|
||||||
|
|
||||||
if group and not explicit_yes_required:
|
if explicit_yes_required:
|
||||||
if is_all:
|
is_yes = res == "y"
|
||||||
|
else:
|
||||||
|
is_yes = res in ("y", "a")
|
||||||
|
|
||||||
|
is_all = res == "a" and group is not None and not explicit_yes_required
|
||||||
|
is_skip = res == "s" and group is not None
|
||||||
|
|
||||||
|
if group:
|
||||||
|
if is_all and not explicit_yes_required:
|
||||||
group.preference = "a"
|
group.preference = "a"
|
||||||
elif is_skip:
|
elif is_skip:
|
||||||
group.preference = "s"
|
group.preference = "s"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue