优化:规则表格加分隔线、ID移至末列、长文本截断
This commit is contained in:
1 parent
81a734af6d
commit
f72b05f2d2
1 file changed
+9
-7
@@ -52,24 +52,26 @@ def cmd_detail(agent_id: str = typer.Argument(..., help="Agent ID")):
|
||||
# 关联规则列表
|
||||
rules = d.get("agentRule", [])
|
||||
if rules:
|
||||
table = Table(title="关联规则", show_lines=False)
|
||||
table.add_column("规则描述")
|
||||
table = Table(title="关联规则", show_lines=True)
|
||||
table.add_column("规则描述", max_width=24, no_wrap=True)
|
||||
table.add_column("规则编码", style="dim", no_wrap=True)
|
||||
table.add_column("ID", style="dim", no_wrap=True)
|
||||
table.add_column("适用场景")
|
||||
table.add_column("适用场景", max_width=16, no_wrap=True)
|
||||
table.add_column("风险等级", no_wrap=True)
|
||||
table.add_column("更新日期", style="dim", no_wrap=True)
|
||||
table.add_column("ID", style="dim", no_wrap=True)
|
||||
for r in rules:
|
||||
level = r.get("level", "")
|
||||
level_str = f"[red]{level}[/red]" if level == "严重" else f"[yellow]{level}[/yellow]"
|
||||
update_date = (r.get("updateTime", "") or "")[:10]
|
||||
desc = r.get("description", "")
|
||||
purpose = r.get("purpose", "")
|
||||
table.add_row(
|
||||
r.get("description", ""),
|
||||
desc,
|
||||
r.get("code", ""),
|
||||
r.get("id", ""),
|
||||
r.get("purpose", ""),
|
||||
purpose,
|
||||
level_str,
|
||||
update_date,
|
||||
r.get("id", ""),
|
||||
)
|
||||
console.print(table)
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user