Files
sap-cli-skill/assets/sapcli/commands/enhancement.py
T
wurangyu 38e99638c5 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
2026-07-10 19:13:46 +08:00

70 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""enhancement 命令 — 查询对象的增强实现。"""
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.enhancement")
def cmd_enhancement(args: argparse.Namespace, client: ADTClient) -> None:
"""查询对象的增强实现(ENHO)。"""
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:
enhancements = client.get_enhancements(parsed.obj_uri)
except Exception as e:
print(f" ✗ 查询增强实现失败: {e}")
return
if not enhancements:
print(" 未找到增强实现")
return
print(f" ✓ 找到 {len(enhancements)} 个增强实现\n")
for enh in enhancements:
enh_name = enh.get("name", "")
enh_type = enh.get("type", "ENHO")
print(f" Enhancement Implementation: {enh_name} ({enh_type})")
enhanced_name = enh.get("enhanced_name", "")
enhanced_type = enh.get("enhanced_type", "")
if enhanced_name:
print(f" Enhanced Object: {enhanced_name} ({enhanced_type})")
elements = enh.get("elements", [])
for i, el in enumerate(elements, 1):
el_type = el.get("type", "")
el_name = el.get("name", "")
label = f"{el_type}: {el_name}" if el_type and el_name else (el_name or el_type)
print(f" Element {i}: {label}")
extras = []
if el.get("mode"):
extras.append(f"Mode: {el['mode']}")
if el.get("replacing"):
extras.append(f"Replacing: {el['replacing']}")
if extras:
print(f" {', '.join(extras)}")
print()