gpt4 book ai didi

github - Jsonnet 的 std.lines(arr) 函数示例

转载 作者:行者123 更新时间:2023-12-05 05:13:39 27 4
gpt4 key购买 nike

谁能帮我举个 Jsonnet 的 std.lines(arr) 函数的例子?我正在尝试创建一个 bash 脚本来使用数组中的值克隆多个 git 存储库。我的数组结构如下。

git repo :[
{
github_repo: "github.com/abcd.git",
github_id:“汤姆”,
github_access_token:“1aae0a6dc19aef327565”
},
{
github_repo: "github.com/qwerty.git",
github_id:“爱丽丝”,
github_access_token:“2e2eef327565”
},
],
}

提前致谢...

最佳答案

从 jsonnet google groups 找到了解决方案。

local config = [
{
github_repo: 'github.com/abcd.git',
github_id: 'tom',
github_access_token: '1aae0a6dc19aef327565',
},
{
github_repo: 'github.com/qwerty.git',
github_id: 'alice',
github_access_token: '2e2eef327565',
},
];
std.lines([
'git clone %(github_repo)s --user=%(github_id)s --token=%(github_access_token)s' % item
for item in config
])

使用 jsonnet -S test.jsonnet 对其进行测试。 (注意大写 -S 标志)

https://groups.google.com/forum/#!searchin/jsonnet/array%7Csort:date/jsonnet/SGADdQQ-vBs/Tig8DnsRBQAJ

关于github - Jsonnet 的 std.lines(arr) 函数示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53368527/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com