toml

toml 用于读取和修改常见 TOML 子集:表、点键、标量值和简单列表。验证和写入都直接针对所选文件。

数据版本 1.1.6稳定
lil-terminal

概览

toml 直接处理常见 TOML 配置:读取点路径,搜索键或值,原子修改一项设置,验证受支持的子集,并输出完整的规范化源文本。

表会变成点路径

含有 host 的 [database] 表可通过 database.host 访问。解析器面向常见主机配置;复杂 TOML 结构更适合按文本编辑。

语法

lil-terminal
toml <file> [key|options] · toml dump <file>

参考

toml <file>

显示 TOML 数据

toml <file> <key>

显示一个精确的点路径

toml dump <file>

显示规范化的 TOML 源文本

-f <text|mask> [-k|-v]

在键或值中查找匹配项;* 和 ? 表示掩码

-w <key> : <value>

直接把值写入文件

-w <key> < <file>

写入从另一个文件读取的值

-d <key>

按点路径删除值

-c

验证 TOML 文件

读取、搜索和修改配置

先运行 toml config/app.toml 查看全部设置,再用 database.host 读取具体值。-f 搜索键路径和内容,-k 只搜键,-v 只搜值。普通文本不区分大小写,* 和 ? 表示整项通配模式。-c 检查格式,dump 显示重新生成的文本。

-w <key> : <value> 会立即保存,-w <key> < <file> 从其他文件读取值,-d <key> 删除路径。数字和 true/false 可能被识别为特定数据类型,写入前应备份。$ 指向 Core 最近打开的文件;只输入文件名也可能调用已注册的处理器。

格式限制与安全编辑

支持常见节、字符串、数字、布尔值及 JSON 风格的数组;不支持 TOML 日期、表数组、特殊数字等完整语法,重复键和节会报错。保存会重建文件并丢失注释与格式。复杂 TOML 请用 edit 或 code。Minimum 只能查看文件。

交互式 sandbox 预览

可直接在页面中运行预先准备的示例。结果已预先生成并在浏览器中显示;服务器不会执行任何终端命令。

打开文件并通过 $ 继续使用

安装与管理

安装当前兼容版本。完整功能请选择 Base,精简包请选择 Minimum;已安装模块的更新请使用 upgrade。

Base 与 Minimum 是同一当前模块版本的两个包。

Base 包

安装包含本地参考和全部已发布模式的完整包。

install toml
Minimum 包

安装精简包。该包不包含本地参考;help <cmd> -i 会打开当前服务器参考。

install toml -m
精确公开版本

安装这个确切的已发布版本。

install toml -v 1.1.6
检查或升级

让 upgrade 检查兼容性,仅在需要时替换已安装块。

upgrade toml
删除模块

删除扩展块,不影响核心和其他模块。

install toml -u

示例

示例可复制,但网站不会执行。请先检查路径、权限和破坏性选项。

打开文件并通过 $ 继续使用
cd \sandbox\config | toml app.toml
application.name    lil-shop
application.debug   true
database.host       localhost
database.port       3306
database.options.0  utf8mb4
database.options.1  strict
显示 TOML 数据
toml config/app.toml
application.name    lil-shop
application.debug   true
database.host       localhost
database.port       3306
database.options.0  utf8mb4
database.options.1  strict
显示一个精确的点路径
toml config/app.toml database.host
localhost
显示一个精确的点路径
toml config/app.toml database.options.0
utf8mb4
在键或值中查找匹配项;* 和 ? 表示掩码
toml config/app.toml -f "database.*" -k
database.host       localhost
database.port       3306
database.options.0  utf8mb4
database.options.1  strict
在键或值中查找匹配项;* 和 ? 表示掩码
toml config/app.toml -f "strict" -v
database.options.1  strict
在键或值中查找匹配项;* 和 ? 表示掩码
toml config/app.toml -f "debug"
application.debug  true
直接把值写入文件
toml config/app.toml -w database.port : 3307
database.port  3307
写入从另一个文件读取的值
toml config/app.toml -w application.name < config/plain-value.txt
application.name  demo-site
处理不存在的文件
toml config/app.toml -d application.debug
application.name    lil-shop
database.host       localhost
database.port       3306
database.options.0  utf8mb4
database.options.1  strict
验证 TOML 文件
toml config/app.toml -c
Valid TOML
显示规范化的 TOML 源文本
toml dump config/app.toml
[application]
name = "lil-shop"
debug = true

[database]
host = "localhost"
port = 3306
options = ["utf8mb4","strict"]
显示一个精确的点路径
toml config/app.toml unknown.key
Path not found
验证 TOML 文件
toml config/invalid.toml -c
Duplicate TOML key
显示 TOML 数据
toml config/missing.toml
File not found
直接把值写入文件
toml config/app.toml -w database.port
Value required after : or 

本示例使用的文件: sandbox/config/app.toml

该示例使用受保护的 /sandbox/ 文档工作区中的文件或目录。

[application]
name = "lil-shop"
debug = true

[database]
host = "localhost"
port = 3306
options = ["utf8mb4", "strict"]

相关文档

当前公开版本

v1.1.62026-11-01

生产级完善

toml 的当前稳定版本。toml 用于读取和修改常见 TOML 子集:表、点键、标量值和简单列表。