mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35: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_aider_commit_hash = None
|
||||||
last_asked_for_commit_time = 0
|
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.abs_fnames = set()
|
||||||
|
|
||||||
self.io = getinput.InputOutput(pretty, yes)
|
self.io = io
|
||||||
|
|
||||||
self.history_file = history_file
|
|
||||||
self.auto_commits = auto_commits
|
self.auto_commits = auto_commits
|
||||||
|
|
||||||
if pretty:
|
if pretty:
|
||||||
|
@ -196,7 +195,7 @@ class Coder:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def run_loop(self):
|
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
|
self.num_control_c = 0
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,10 @@ class FileContentCompleter(Completer):
|
||||||
|
|
||||||
|
|
||||||
class InputOutput:
|
class InputOutput:
|
||||||
def __init__(self, pretty, yes):
|
def __init__(self, pretty, yes, history_file):
|
||||||
self.pretty = pretty
|
self.pretty = pretty
|
||||||
self.yes = yes
|
self.yes = yes
|
||||||
|
self.history_file = history_file
|
||||||
|
|
||||||
if pretty:
|
if pretty:
|
||||||
self.console = Console()
|
self.console = Console()
|
||||||
|
@ -74,7 +75,7 @@ class InputOutput:
|
||||||
console.print()
|
console.print()
|
||||||
return input_line
|
return input_line
|
||||||
|
|
||||||
def get_input(self, history_file, fnames, commands):
|
def get_input(self, fnames, commands):
|
||||||
if self.pretty:
|
if self.pretty:
|
||||||
self.console.rule()
|
self.console.rule()
|
||||||
else:
|
else:
|
||||||
|
@ -112,7 +113,7 @@ class InputOutput:
|
||||||
line = prompt(
|
line = prompt(
|
||||||
show,
|
show,
|
||||||
completer=completer_instance,
|
completer=completer_instance,
|
||||||
history=FileHistory(history_file),
|
history=FileHistory(self.history_file),
|
||||||
style=style,
|
style=style,
|
||||||
reserve_space_for_menu=4,
|
reserve_space_for_menu=4,
|
||||||
complete_style=CompleteStyle.MULTI_COLUMN,
|
complete_style=CompleteStyle.MULTI_COLUMN,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import sys
|
||||||
import argparse
|
import argparse
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from aider.coder import Coder
|
from aider.coder import Coder
|
||||||
|
from aider.getinput import InputOutput
|
||||||
|
|
||||||
def main(args=None):
|
def main(args=None):
|
||||||
if args is None:
|
if args is None:
|
||||||
|
@ -75,8 +75,10 @@ def main(args=None):
|
||||||
fnames = args.files
|
fnames = args.files
|
||||||
pretty = args.pretty
|
pretty = args.pretty
|
||||||
|
|
||||||
|
io = InputOutput(args.pretty, args.yes, args.history_file)
|
||||||
|
|
||||||
coder = Coder(
|
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")
|
coder.commit(ask=True, prefix="wip: ", which="repo_files")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue