跳转到内容

cnb-rs config get

cnb-rs config get <key>

获取指定配置项的当前值。对齐 gh config get

如果配置项未设置,输出为空(未加 (default) 标注,表示「未设置」与「用户显式设为空」区分)。需要默认值请看 cnb-rs config list

参数

  • <key>: 配置项名称。可选值:
    • domain
    • git_protocol
    • templates.gitignore_repo(嵌套 key)
    • templates.license_repo(嵌套 key)

继承的全局选项:

  • --json:以 JSON 输出含 key + value 两个字段,未设置时 value: null

示例

bash
# 获取默认域名(未设置过,输出为空)
$ cnb-rs config get domain


# 获取嵌套 key
$ cnb-rs config get templates.gitignore_repo
cnb/skills/gitignore-templates

# JSON 格式
$ cnb-rs config get domain --json
{
  "key": "domain",
  "value": null
}

# 未知 key → friendly bail
$ cnb-rs config get foo
错误: 未知配置项:foo
可用配置项:domain, git_protocol, templates.gitignore_repo, templates.license_repo

另请参阅

Released under the MIT License.