chore: sync skill to v2.2.1

- NW 7.40 E2E-verified compatibility matrix in SKILL.md
- DDIC fixes: include namespace, tabletype exists check, DDIC delete lock Accept
- New commands: clone, enhancement, history, unit-test
- 665 tests, 96% coverage
This commit is contained in:
2026-07-10 19:13:46 +08:00
parent 3a7fba0860
commit 38e99638c5
16 changed files with 951 additions and 16 deletions
+65
View File
@@ -0,0 +1,65 @@
"""history 命令 — 查询对象版本历史。"""
from __future__ import annotations
import argparse
import logging
from sapcli.client import ADTClient
from sapcli.exceptions import ObjectNotFoundError
from sapcli.types import get_type_config, parse_object_name
logger = logging.getLogger("sapcli.commands.history")
def _format_date(value: str) -> str:
"""ISO 日期 ``2026-06-15T10:30:00`` → ``2026-06-15 10:30:00``。"""
if not value:
return ""
return value.replace("T", " ").rstrip("Z").strip()
def cmd_history(args: argparse.Namespace, client: ADTClient) -> None:
"""查询对象的版本历史。"""
name: str = args.name
obj_type: str = args.type
parsed = parse_object_name(name, obj_type)
type_label = get_type_config(obj_type).label
print("=" * 60)
print(" 对象版本历史")
print("=" * 60)
print(f" 对象类型: {type_label}")
print(f" 对象名称: {parsed.display_name}")
print(f"\n → 检查对象是否存在...")
if not client.object_exists(parsed.obj_uri):
print(f" ✗ 对象不存在: {parsed.display_name}")
raise ObjectNotFoundError(parsed.display_name, obj_type)
print(" ✓ 对象存在")
print(f"\n → 正在查询版本历史...")
try:
versions = client.get_object_versions(parsed.obj_uri)
except Exception as e:
print(f" ✗ 查询版本历史失败: {e}")
return
if not versions:
print(" 未找到版本历史")
return
print(f" ✓ 找到 {len(versions)} 个版本\n")
print(
f" {'Version':<10} {'Author':<12} {'Date':<22} Description"
)
print(
f" {'' * 10} {'' * 12} {'' * 22} {'' * 30}"
)
for v in versions:
version = v.get("version", "") or "active"
author = v.get("author", "")
date = _format_date(v.get("date", ""))
title = v.get("versionTitle", "")
print(f" {version:<10} {author:<12} {date:<22} {title}")
print()