mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
feat: add compact file listing using rich Columns when pretty=True
This commit is contained in:
parent
4c39e92773
commit
42abdb0a41
1 changed files with 29 additions and 9 deletions
38
aider/io.py
38
aider/io.py
|
@ -700,17 +700,37 @@ class InputOutput:
|
||||||
self.chat_history_file = None # Disable further attempts to write
|
self.chat_history_file = None # Disable further attempts to write
|
||||||
|
|
||||||
def format_files_for_input(self, rel_fnames, rel_read_only_fnames):
|
def format_files_for_input(self, rel_fnames, rel_read_only_fnames):
|
||||||
read_only_files = []
|
if not self.pretty:
|
||||||
for full_path in sorted(rel_read_only_fnames or []):
|
read_only_files = []
|
||||||
read_only_files.append(f"{full_path} (read only)")
|
for full_path in sorted(rel_read_only_fnames or []):
|
||||||
|
read_only_files.append(f"{full_path} (read only)")
|
||||||
|
|
||||||
editable_files = []
|
editable_files = []
|
||||||
for full_path in sorted(rel_fnames):
|
for full_path in sorted(rel_fnames):
|
||||||
if full_path in rel_read_only_fnames:
|
if full_path in rel_read_only_fnames:
|
||||||
continue
|
continue
|
||||||
editable_files.append(f"{full_path}")
|
editable_files.append(f"{full_path}")
|
||||||
|
|
||||||
return "\n".join(read_only_files + editable_files) + "\n"
|
return "\n".join(read_only_files + editable_files) + "\n"
|
||||||
|
|
||||||
|
# Use rich Columns for pretty output
|
||||||
|
from rich.columns import Columns
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
|
output = StringIO()
|
||||||
|
console = Console(file=output, force_terminal=False)
|
||||||
|
|
||||||
|
read_only_files = [f"{f} (read only)" for f in sorted(rel_read_only_fnames or [])]
|
||||||
|
editable_files = [f for f in sorted(rel_fnames) if f not in rel_read_only_fnames]
|
||||||
|
|
||||||
|
if read_only_files:
|
||||||
|
console.print(Columns(read_only_files))
|
||||||
|
if editable_files:
|
||||||
|
if read_only_files:
|
||||||
|
console.print()
|
||||||
|
console.print(Columns(editable_files))
|
||||||
|
|
||||||
|
return output.getvalue()
|
||||||
|
|
||||||
|
|
||||||
def get_rel_fname(fname, root):
|
def get_rel_fname(fname, root):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue