← 返回列表
D

dsh-fmt

v0.1.0 · 3 天前发布

DSH plugin: format/validate JSON, YAML, TOML and SQL text.

dsh-pluginformatjsonyamlsql

README

dsh-fmt

DSH 插件:格式化 / 校验文本,支持 JSON / YAML / TOML / SQL 四种格式。纯 ESM、无构建、无原生依赖。

安装

sh
dsh plugin --profile <name> add file:./plugins/dsh-fmt

(发布到 npm 后:dsh plugin --profile <name> add dsh-fmt

工具

  • format_text —— 输入文本与目标格式,返回规范值 { format, ok, output, error? }
  • 参数

    | 参数 | 类型 | 必填 | 默认 | 说明 |
    | --- | --- | --- | --- | --- |
    | text | string | 是 | - | 要格式化 / 校验的文本 |
    | format | enum | 是 | - | json / yaml / toml / sql |
    | indent | number | 否 | 2 | 缩进宽度(JSON/YAML 美化;SQL 的 tab 宽度) |
    | sqlDialect | enum | 否 | standard | standard / postgresql / mysql / sqlite,仅 SQL 使用 |
    | keywordCase | enum | 否 | upper | upper / lower / preserve,仅 SQL 使用 |

    返回值

    规范 JSON 值:

    ```jsonc
    {
    "format": "json", // 本次使用的格式
    "ok": true,

    版本兼容矩阵

    DSH 版本状态说明
    dsh@0.1.0-rc.6 ✅ 兼容 cordis patch ✅
    dsh@0.1.0 ✅ 兼容 标准 patch ✅
    dsh@0.2.0 ⚠️ 待验证 待实测(API 可能在变)
    dsh@0.3.0+ ❓ 未知 尚未发布

    💡 兼容矩阵每周末自动跑实测,欢迎 PR 修正

    元数据

    License
    MIT
    npm
    dsh-fmt
    Repo
    Engines
    {}
    Weekly DL
    0
    Monthly DL
    0
    dsh.bundle
    {"bundle":{"patch":"./cordis.patch.yml"}}