mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
fix: Update confirm_ask prompts to use consistent formatting
This commit is contained in:
parent
9fb3a6f8e1
commit
3e5554c24f
3 changed files with 35 additions and 3 deletions
|
@ -1661,7 +1661,7 @@ class Coder:
|
|||
return True
|
||||
|
||||
if not Path(full_path).exists():
|
||||
if not self.io.confirm_ask("Allow creation of new file?", subject=path):
|
||||
if not self.io.confirm_ask("Create new file?", subject=path):
|
||||
self.io.tool_error(f"Skipping edits to {path}")
|
||||
return
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class EditBlockCoder(Coder):
|
|||
if edit[0] is None:
|
||||
edit = edit[1]
|
||||
# This is a shell command
|
||||
if self.io.confirm_ask("Run this shell command?", subject=edit.strip()):
|
||||
if self.io.confirm_ask("Run shell command?", subject=edit.strip()):
|
||||
self.io.tool_output()
|
||||
try:
|
||||
# Add the command to input history
|
||||
|
|
34
aider/io.py
34
aider/io.py
|
@ -356,16 +356,48 @@ class InputOutput:
|
|||
def confirm_ask(self, question, default="y", subject=None):
|
||||
self.num_user_asks += 1
|
||||
|
||||
if default == "y":
|
||||
question += " [Y/n] "
|
||||
elif default == "n":
|
||||
question += " [y/N] "
|
||||
else:
|
||||
question += " [y/n] "
|
||||
|
||||
if subject:
|
||||
self.tool_output()
|
||||
self.tool_output(subject, bold=True)
|
||||
|
||||
if self.pretty and self.user_input_color:
|
||||
style = {"": self.user_input_color}
|
||||
else:
|
||||
style = dict()
|
||||
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
|
||||
completer = WordCompleter(["yes", "no"])
|
||||
|
||||
from prompt_toolkit import prompt
|
||||
from prompt_toolkit.validation import Validator
|
||||
|
||||
def is_yesno(text):
|
||||
return "yes".startswith(text.lower()) or "no".startswith(text.lower())
|
||||
|
||||
validator = Validator.from_callable(
|
||||
is_yesno,
|
||||
error_message="Answer yes or no.",
|
||||
move_cursor_to_end=True,
|
||||
)
|
||||
|
||||
if self.yes is True:
|
||||
res = "y"
|
||||
elif self.yes is False:
|
||||
res = "n"
|
||||
else:
|
||||
res = prompt(question + " ", default=default)
|
||||
res = prompt(
|
||||
question, style=Style.from_dict(style), completer=completer, validator=validator
|
||||
)
|
||||
if not res and default:
|
||||
res = default
|
||||
|
||||
res = res.lower().strip()
|
||||
is_yes = res in ("y", "yes")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue