Fix: support auto width when print table (#10575)

### What problem does this PR solve?

Print table support auto width.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Lynn
2025-10-15 14:57:44 +08:00
committed by GitHub
parent 5037a28e4d
commit 071ea9c493
2 changed files with 4 additions and 4 deletions

View File

@ -341,9 +341,9 @@ class AdminCLI(Cmd):
row = "|"
for col in columns:
value = str(item.get(col, ''))
if len(value) > col_widths[col]:
if get_string_width(value) > col_widths[col]:
value = value[:col_widths[col] - 3] + "..."
row += f" {value:<{col_widths[col]}} |"
row += f" {value:<{col_widths[col] - (get_string_width(value) - len(value))}} |"
print(row)
print(separator)
@ -452,7 +452,7 @@ class AdminCLI(Cmd):
if response.status_code == 200:
self._print_table_simple(res_json['data'])
else:
print(f"Fail to get all users, code: {res_json['code']}, message: {res_json['message']}")
print(f"Fail to get all services, code: {res_json['code']}, message: {res_json['message']}")
def _handle_show_service(self, command):
service_id: int = command['number']

View File

@ -1,6 +1,6 @@
[project]
name = "ragflow-cli"
version = "0.21.0.dev5"
version = "0.21.0.dev9"
description = "Admin Service's client of [RAGFlow](https://github.com/infiniflow/ragflow). The Admin Service provides user management and system monitoring. "
authors = [{ name = "Lynn", email = "lynn_inf@hotmail.com" }]
license = { text = "Apache License, Version 2.0" }