mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 19:55:00 +00:00
Refactor InputOutput class to accept history_file as an argument and remove it from get_input method.
This commit is contained in:
parent
b074cae5c7
commit
4ff5b0e115
3 changed files with 11 additions and 9 deletions
|
@ -29,12 +29,11 @@ class Coder:
|
|||
last_aider_commit_hash = None
|
||||
last_asked_for_commit_time = 0
|
||||
|
||||
def __init__(self, main_model, fnames, pretty, history_file, show_diffs, auto_commits, yes):
|
||||
def __init__(self, main_model, fnames, pretty, show_diffs, auto_commits, io):
|
||||
self.abs_fnames = set()
|
||||
|
||||
self.io = getinput.InputOutput(pretty, yes)
|
||||
self.io = io
|
||||
|
||||
self.history_file = history_file
|
||||
self.auto_commits = auto_commits
|
||||
|
||||
if pretty:
|
||||
|
@ -196,7 +195,7 @@ class Coder:
|
|||
return True
|
||||
|
||||
def run_loop(self):
|
||||
inp = self.io.get_input(self.history_file, self.abs_fnames, self.commands)
|
||||
inp = self.io.get_input(self.abs_fnames, self.commands)
|
||||
|
||||
self.num_control_c = 0
|
||||
|
||||
|
|
|
@ -52,9 +52,10 @@ class FileContentCompleter(Completer):
|
|||
|
||||
|
||||
class InputOutput:
|
||||
def __init__(self, pretty, yes):
|
||||
def __init__(self, pretty, yes, history_file):
|
||||
self.pretty = pretty
|
||||
self.yes = yes
|
||||
self.history_file = history_file
|
||||
|
||||
if pretty:
|
||||
self.console = Console()
|
||||
|
@ -74,7 +75,7 @@ class InputOutput:
|
|||
console.print()
|
||||
return input_line
|
||||
|
||||
def get_input(self, history_file, fnames, commands):
|
||||
def get_input(self, fnames, commands):
|
||||
if self.pretty:
|
||||
self.console.rule()
|
||||
else:
|
||||
|
@ -112,7 +113,7 @@ class InputOutput:
|
|||
line = prompt(
|
||||
show,
|
||||
completer=completer_instance,
|
||||
history=FileHistory(history_file),
|
||||
history=FileHistory(self.history_file),
|
||||
style=style,
|
||||
reserve_space_for_menu=4,
|
||||
complete_style=CompleteStyle.MULTI_COLUMN,
|
||||
|
|
|
@ -3,7 +3,7 @@ import sys
|
|||
import argparse
|
||||
from dotenv import load_dotenv
|
||||
from aider.coder import Coder
|
||||
|
||||
from aider.getinput import InputOutput
|
||||
|
||||
def main(args=None):
|
||||
if args is None:
|
||||
|
@ -75,8 +75,10 @@ def main(args=None):
|
|||
fnames = args.files
|
||||
pretty = args.pretty
|
||||
|
||||
io = InputOutput(args.pretty, args.yes, args.history_file)
|
||||
|
||||
coder = Coder(
|
||||
args.model, fnames, pretty, args.history_file, args.show_diffs, args.auto_commits, args.yes
|
||||
args.model, fnames, pretty, args.show_diffs, args.auto_commits, io,
|
||||
)
|
||||
coder.commit(ask=True, prefix="wip: ", which="repo_files")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue