mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
PKL write api #353
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @casperwtf on GitHub (Nov 1, 2025).
Hi, I have PKL as a file on disk, I want to have my application write default values to the PKL files at a given path, is there an api for that?
@HT154 commented on GitHub (Nov 1, 2025):
Hi there! This is an area we've given some thought to. There are some challenges due to Pkl's more dynamic features like generators and functions that present obstacles to reading, transforming, and writing Pkl files.
That said, there some techniques you can use that may work for your needs:
Reading values from static files
You can write your set of default values in a static format like YAML or JSON and read this data in your Pkl code. For example:
Depending on your scenario, you may even be able to read the YAML/JSON data over HTTPS instead of needing to write it to a local file.
Generate an entire Pkl file
The Pkl team maintains a library called
pkl.experimental.syntaxthat can be used to generate Pkl code from an in-language representation of the syntax tree. While there's no way to read an existing Pkl file into this representation, it still may be useful to you if you structure your modules effectively:@casperwtf commented on GitHub (Nov 20, 2025):
I am on java, is there any java equivalent