allow commands to reply to gpt; /undo tells it with discarded the changes

This commit is contained in:
Paul Gauthier 2023-05-10 18:08:33 -07:00
parent fcacc3c139
commit bce64f1986
2 changed files with 9 additions and 4 deletions

View file

@ -183,7 +183,8 @@ class Coder:
inp = get_input(self.history_file, self.abs_fnames, self.commands) inp = get_input(self.history_file, self.abs_fnames, self.commands)
if inp.startswith("/"): if inp.startswith("/"):
self.commands.run(inp) inp = self.commands.run(inp)
if not inp:
return return
self.num_control_c = 0 self.num_control_c = 0

View file

@ -39,7 +39,7 @@ class Commands:
cmd_method_name = f"cmd_{cmd_name}" cmd_method_name = f"cmd_{cmd_name}"
cmd_method = getattr(self, cmd_method_name, None) cmd_method = getattr(self, cmd_method_name, None)
if cmd_method: if cmd_method:
cmd_method(args) return cmd_method(args)
else: else:
self.console.print(f"Error: Command {cmd_name} not found.") self.console.print(f"Error: Command {cmd_name} not found.")
@ -105,7 +105,11 @@ class Commands:
) )
return return
self.coder.repo.git.reset("--hard", "HEAD~1") self.coder.repo.git.reset("--hard", "HEAD~1")
self.console.print(f"[red]Undid the last commit: {last_commit.message.strip()}") self.console.print(
f"[red]Undid the last commit: {last_commit.message.strip()}\n"
)
return "I did not like those edits, so I did `git reset --hard HEAD~1` to discard them."
def cmd_diff(self, args): def cmd_diff(self, args):
"Display the diff of the last aider commit" "Display the diff of the last aider commit"