mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
fully implement --no-pretty
This commit is contained in:
parent
862b3c5cc1
commit
e1fd8b0edc
1 changed files with 27 additions and 12 deletions
31
coder.py
31
coder.py
|
@ -42,7 +42,7 @@ class Coder:
|
||||||
fnames = dict()
|
fnames = dict()
|
||||||
last_modified = 0
|
last_modified = 0
|
||||||
|
|
||||||
def __init__(self, use_gpt_4, files, colorize):
|
def __init__(self, use_gpt_4, files, pretty):
|
||||||
if use_gpt_4:
|
if use_gpt_4:
|
||||||
self.main_model = "gpt-4"
|
self.main_model = "gpt-4"
|
||||||
else:
|
else:
|
||||||
|
@ -53,8 +53,12 @@ class Coder:
|
||||||
|
|
||||||
self.check_for_local_edits(True)
|
self.check_for_local_edits(True)
|
||||||
|
|
||||||
|
self.pretty = pretty
|
||||||
|
|
||||||
|
if pretty:
|
||||||
self.console = Console()
|
self.console = Console()
|
||||||
self.colorize = colorize
|
else:
|
||||||
|
self.console = Console(force_terminal=True, no_color=True)
|
||||||
|
|
||||||
def files_modified(self):
|
def files_modified(self):
|
||||||
for fname, mtime in self.fnames.items():
|
for fname, mtime in self.fnames.items():
|
||||||
|
@ -79,10 +83,18 @@ class Coder:
|
||||||
return prompt
|
return prompt
|
||||||
|
|
||||||
def get_input(self):
|
def get_input(self):
|
||||||
|
if self.pretty:
|
||||||
self.console.rule()
|
self.console.rule()
|
||||||
|
else:
|
||||||
|
print()
|
||||||
|
|
||||||
inp = ""
|
inp = ""
|
||||||
num_control_c = 0
|
num_control_c = 0
|
||||||
|
if self.pretty:
|
||||||
print(Fore.GREEN, end="\r")
|
print(Fore.GREEN, end="\r")
|
||||||
|
else:
|
||||||
|
print()
|
||||||
|
|
||||||
while not inp.strip():
|
while not inp.strip():
|
||||||
try:
|
try:
|
||||||
inp = input("> ")
|
inp = input("> ")
|
||||||
|
@ -96,7 +108,10 @@ class Coder:
|
||||||
self.console.print("[bold red]^C again to quit")
|
self.console.print("[bold red]^C again to quit")
|
||||||
|
|
||||||
###
|
###
|
||||||
|
if self.pretty:
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
|
else:
|
||||||
|
print()
|
||||||
|
|
||||||
readline.write_history_file(history_file)
|
readline.write_history_file(history_file)
|
||||||
return inp
|
return inp
|
||||||
|
@ -216,7 +231,7 @@ class Coder:
|
||||||
|
|
||||||
if show_progress:
|
if show_progress:
|
||||||
return self.show_send_progress(completion, show_progress)
|
return self.show_send_progress(completion, show_progress)
|
||||||
elif self.colorize:
|
elif self.pretty:
|
||||||
return self.show_send_output_color(completion)
|
return self.show_send_output_color(completion)
|
||||||
else:
|
else:
|
||||||
return self.show_send_output_plain(completion)
|
return self.show_send_output_plain(completion)
|
||||||
|
@ -385,20 +400,20 @@ def main():
|
||||||
help="Only use gpt-3.5-turbo, not gpt-4",
|
help="Only use gpt-3.5-turbo, not gpt-4",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-color",
|
"--no-pretty",
|
||||||
action="store_false",
|
action="store_false",
|
||||||
dest="colorize",
|
dest="pretty",
|
||||||
default=True,
|
default=True,
|
||||||
help="Disable colorized output of GPT responses",
|
help="Disable prettyd output of GPT responses",
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
use_gpt_4 = not args.gpt_3_5_turbo
|
use_gpt_4 = not args.gpt_3_5_turbo
|
||||||
fnames = args.files
|
fnames = args.files
|
||||||
colorize = args.colorize
|
pretty = args.pretty
|
||||||
|
|
||||||
coder = Coder(use_gpt_4, fnames, colorize)
|
coder = Coder(use_gpt_4, fnames, pretty)
|
||||||
coder.run()
|
coder.run()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue