-
hi community. Now let's say I don't want to do it manually anymore, I want to use an automatic way. within an github action for example.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Pkl isn't meant to be written to programmatically. However, if your data is meant to come from an automated source, you can use For example, if your data is simply a version file: version = read("path/to/version.txt").text.trim() Or if your data is JSON, you'd use an read-then-parse technique: import "pkl:json"
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped@1.1.0#/deepToTyped.pkl"
local parser = new json.Parser {}
class MyData {
foo: String
bar: Int
}
parsed = parser.parse(read("path/to/data.json"))
myData = deepToTyped.apply(MyData, parsed) |
Beta Was this translation helpful? Give feedback.
If you have known values that you'd like to be able to override from the CLI, you should look into using
read()
for that. For example, your code can look like:Then, you can eval via:
pkl eval -p team-a=1000 myModule.pkl
If you don't have a program that allows you to override specific values using
read()
,-x
is a good escape hatch (like you mentioned). For example:This is a little more fragile, though, because you are relying on shell scripting to construct valid Pkl…