feat: --format json/yaml/table for all non-interactive commands #329

Merged
xiaomo merged 1 commits from feat/328-format-option into main 2026-05-18 13:36:03 +00:00
Owner

What

所有非交互 uwf 命令支持 --format json/yaml/table

Changes

  • 新建 format.tsformatOutput(data, format) 统一输出
  • cli.ts — program 级 --format 选项,替换 writeJsonwriteOutput

示例

# 默认 JSON(不变)
uwf cas has 0000000000000{"exists":false}

# YAML
uwf --format yaml cas has 0000000000000
→ exists: false

# Table
uwf --format table cas schema list
→ HASH           TITLE
  056WS17E5F9E5  (meta-schema)

Closes #328

## What 所有非交互 uwf 命令支持 `--format json/yaml/table`。 ## Changes - 新建 `format.ts` — `formatOutput(data, format)` 统一输出 - `cli.ts` — program 级 `--format` 选项,替换 `writeJson` 为 `writeOutput` ## 示例 ```bash # 默认 JSON(不变) uwf cas has 0000000000000 → {"exists":false} # YAML uwf --format yaml cas has 0000000000000 → exists: false # Table uwf --format table cas schema list → HASH TITLE 056WS17E5F9E5 (meta-schema) ``` Closes #328
xiaoju added 1 commit 2026-05-18 13:33:58 +00:00
Add program-level --format option (default: json) inherited by all
subcommands. json output unchanged, yaml via yaml package, table
renders aligned columns for arrays, falls back to yaml for objects.

Closes #328

小橘 🍊(NEKO Team)
xiaomo approved these changes 2026-05-18 13:36:01 +00:00
xiaomo left a comment
Owner

LGTM format.ts 干净,table 非数组退化 yaml 也合理。

LGTM ✅ format.ts 干净,table 非数组退化 yaml 也合理。
xiaomo merged commit ec0bc672f6 into main 2026-05-18 13:36:03 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#329